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
ip_parse_common_args.c
ipaddress.c *: hopefully all setup_common_bufsiz() are in place 2016-04-21 18:38:51 +02:00
iplink.c
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
libnetlink.c libnetlink: fix alignment of netlink messages 2016-09-18 22:55:47 +02:00
libnetlink.h
ll_addr.c
ll_map.c libiproute: use if_nametoindex 2015-10-24 22:04:36 +02:00
ll_map.h
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
rt_names.h
rtm_map.c
rtm_map.h
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