Fix struct alignment with cris architecture

[IPROUTE]: Fix struct alignment with cris architecture

gcc for the cris arch does not pad structures to the next multiple of 4
bytes, as the i386 gcc does.

This causes errors like this when displaying xfrm policies:

# ip x p
!!!Deficit 3, rta_len=300
src 192.168.251.32/29 dst 192.168.251.32/29
        dir in priority 0
!!!Deficit 3, rta_len=180
src 0.0.0.0/0 dst 192.168.251.32/29
        dir in priority 2208
....

Similar errors are seen from ip x s.

This patch fixes the errors when printing. I'm not sure whether we
should worry about other uses of the affected structs, I've not seen any
other bad effects from this though, so hopefully this is enough.

(Thanks to Herbert Xu for pointing out that NLMSG_SPACE is the correct
macro to use here.)

Tested against 2.6.17.6 kernel on i386, and 2.6.16.1 kernel on cris.

Signed-off-by: Andy Gay <andy@andynet.net>
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
This commit is contained in:
Andy Gay 2006-08-10 20:25:40 -04:00 committed by Stephen Hemminger
parent 34e9564753
commit af1b6a41d4
2 changed files with 6 additions and 6 deletions

View File

@ -354,15 +354,15 @@ int xfrm_policy_print(const struct sockaddr_nl *who, struct nlmsghdr *n,
if (n->nlmsg_type == XFRM_MSG_DELPOLICY) { if (n->nlmsg_type == XFRM_MSG_DELPOLICY) {
xpid = NLMSG_DATA(n); xpid = NLMSG_DATA(n);
len -= NLMSG_LENGTH(sizeof(*xpid)); len -= NLMSG_SPACE(sizeof(*xpid));
} else if (n->nlmsg_type == XFRM_MSG_POLEXPIRE) { } else if (n->nlmsg_type == XFRM_MSG_POLEXPIRE) {
xpexp = NLMSG_DATA(n); xpexp = NLMSG_DATA(n);
xpinfo = &xpexp->pol; xpinfo = &xpexp->pol;
len -= NLMSG_LENGTH(sizeof(*xpexp)); len -= NLMSG_SPACE(sizeof(*xpexp));
} else { } else {
xpexp = NULL; xpexp = NULL;
xpinfo = NLMSG_DATA(n); xpinfo = NLMSG_DATA(n);
len -= NLMSG_LENGTH(sizeof(*xpinfo)); len -= NLMSG_SPACE(sizeof(*xpinfo));
} }
if (len < 0) { if (len < 0) {

View File

@ -575,15 +575,15 @@ int xfrm_state_print(const struct sockaddr_nl *who, struct nlmsghdr *n,
if (n->nlmsg_type == XFRM_MSG_DELSA) { if (n->nlmsg_type == XFRM_MSG_DELSA) {
/* Dont blame me for this .. Herbert made me do it */ /* Dont blame me for this .. Herbert made me do it */
xsid = NLMSG_DATA(n); xsid = NLMSG_DATA(n);
len -= NLMSG_LENGTH(sizeof(*xsid)); len -= NLMSG_SPACE(sizeof(*xsid));
} else if (n->nlmsg_type == XFRM_MSG_EXPIRE) { } else if (n->nlmsg_type == XFRM_MSG_EXPIRE) {
xexp = NLMSG_DATA(n); xexp = NLMSG_DATA(n);
xsinfo = &xexp->state; xsinfo = &xexp->state;
len -= NLMSG_LENGTH(sizeof(*xexp)); len -= NLMSG_SPACE(sizeof(*xexp));
} else { } else {
xexp = NULL; xexp = NULL;
xsinfo = NLMSG_DATA(n); xsinfo = NLMSG_DATA(n);
len -= NLMSG_LENGTH(sizeof(*xsinfo)); len -= NLMSG_SPACE(sizeof(*xsinfo));
} }
if (len < 0) { if (len < 0) {