busybox/networking/libiproute
Hauke Mehrtens 4ff86df861 libnetlink: fix alignment of netlink messages
A padding to align a message should not only be added between
different attributes of a netlink message, but also at the end of the
message to pad it to the correct size.

Without this patch the following command does not work and returns an
error code:
ip link add type nlmon

Without this ip from busybox sends this:

sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000},
	msg_namelen=12, msg_iov=[{iov_base={{len=45, ...},
		"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\22\0\t\0\1nlmon"}, iov_len=45}],
	msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 45
return value: 2

The normal ip utile from iproute2 sends this:

sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000},
	msg_namelen=12, msg_iov=[{iov_base={{len=48, ...},
		"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\22\0\t\0\1nlmon\0\0\0"}, iov_len=48}],
	msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 48
return value: 0

With this patch ip from busybox sends this:

sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000},
	msg_namelen=12, msg_iov=[{iov_base={{len=48, ...},
		"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\20\0\22\0\t\0\1nlmon\0\0\0"}, iov_len=48}],
	msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 48
return value: 0

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-18 22:55:47 +02:00
..
ip_common.h networking: add 'ip neigh' command 2015-10-14 12:53:47 +02:00
ip_parse_common_args.c libiproute: rename invarg(a,b) to invarg_1_to_2(a,b) 2015-10-14 13:21:01 +02:00
ipaddress.c *: hopefully all setup_common_bufsiz() are in place 2016-04-21 18:38:51 +02:00
iplink.c libiproute: rename invarg(a,b) to invarg_1_to_2(a,b) 2015-10-14 13:21:01 +02:00
ipneigh.c *: slap on a few ALIGN1/2s where appropriate 2016-04-22 18:09:21 +02:00
iproute.c ip: fix an improper optimization: req.r.rtm_scope may be nonzero here 2016-08-14 01:30:34 +02:00
iprule.c libiproute: eliminate some redundant zero stores 2016-08-14 02:08:56 +02:00
iptunnel.c libiproute: make rt_addr_n2a() and format_host() return auto strings 2015-10-14 13:56:42 +02:00
Kbuild.src networking: add 'ip neigh' command 2015-10-14 12:53:47 +02:00
libnetlink.c libnetlink: fix alignment of netlink messages 2016-09-18 22:55:47 +02:00
libnetlink.h whitespace cleanup 2010-10-29 11:46:52 +02:00
ll_addr.c whitespace cleanup 2010-10-29 11:46:52 +02:00
ll_map.c libiproute: use if_nametoindex 2015-10-24 22:04:36 +02:00
ll_map.h libbb: auto_string() for efficient handling of temporary malloced stirngs 2015-10-09 17:59:56 +02:00
ll_proto.c *: slap on a few ALIGN1/2s where appropriate 2016-04-22 18:09:21 +02:00
ll_types.c *: slap on a few ALIGN1/2s where appropriate 2016-04-22 18:09:21 +02:00
rt_names.c iproute: more string reuse 2015-10-08 17:15:08 +02:00
rt_names.h libiproute: use itoa() where appropriate 2015-10-08 13:02:28 +02:00
rtm_map.c libiproute: use itoa() where appropriate 2015-10-08 13:02:28 +02:00
rtm_map.h libiproute: use itoa() where appropriate 2015-10-08 13:02:28 +02:00
utils.c libiproute: make rt_addr_n2a() and format_host() return auto strings 2015-10-14 13:56:42 +02:00
utils.h libiproute: make rt_addr_n2a() and format_host() return auto strings 2015-10-14 13:56:42 +02:00