Skip to content

Commit bd4a816

Browse files
zenczykowskidavem330
authored andcommitted
net: ipv6: support reporting otherwise unknown prefix flags in RTM_NEWPREFIX
Lorenzo points out that we effectively clear all unknown flags from PIO when copying them to userspace in the netlink RTM_NEWPREFIX notification. We could fix this one at a time as new flags are defined, or in one fell swoop - I choose the latter. We could either define 6 new reserved flags (reserved1..6) and handle them individually (and rename them as new flags are defined), or we could simply copy the entire unmodified byte over - I choose the latter. This unfortunately requires some anonymous union/struct magic, so we add a static assert on the struct size for a little extra safety. Cc: David Ahern <[email protected]> Cc: Lorenzo Colitti <[email protected]> Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: Maciej Żenczykowski <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e5dc5af commit bd4a816

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

include/net/addrconf.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,32 @@ struct prefix_info {
3131
__u8 length;
3232
__u8 prefix_len;
3333

34+
union __packed {
35+
__u8 flags;
36+
struct __packed {
3437
#if defined(__BIG_ENDIAN_BITFIELD)
35-
__u8 onlink : 1,
38+
__u8 onlink : 1,
3639
autoconf : 1,
3740
reserved : 6;
3841
#elif defined(__LITTLE_ENDIAN_BITFIELD)
39-
__u8 reserved : 6,
42+
__u8 reserved : 6,
4043
autoconf : 1,
4144
onlink : 1;
4245
#else
4346
#error "Please fix <asm/byteorder.h>"
4447
#endif
48+
};
49+
};
4550
__be32 valid;
4651
__be32 prefered;
4752
__be32 reserved2;
4853

4954
struct in6_addr prefix;
5055
};
5156

57+
/* rfc4861 4.6.2: IPv6 PIO is 32 bytes in size */
58+
static_assert(sizeof(struct prefix_info) == 32);
59+
5260
#include <linux/ipv6.h>
5361
#include <linux/netdevice.h>
5462
#include <net/if_inet6.h>

include/net/if_inet6.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
#define IF_RS_SENT 0x10
2323
#define IF_READY 0x80000000
2424

25-
/* prefix flags */
26-
#define IF_PREFIX_ONLINK 0x01
27-
#define IF_PREFIX_AUTOCONF 0x02
28-
2925
enum {
3026
INET6_IFADDR_STATE_PREDAD,
3127
INET6_IFADDR_STATE_DAD,

net/ipv6/addrconf.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6149,11 +6149,7 @@ static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
61496149
pmsg->prefix_len = pinfo->prefix_len;
61506150
pmsg->prefix_type = pinfo->type;
61516151
pmsg->prefix_pad3 = 0;
6152-
pmsg->prefix_flags = 0;
6153-
if (pinfo->onlink)
6154-
pmsg->prefix_flags |= IF_PREFIX_ONLINK;
6155-
if (pinfo->autoconf)
6156-
pmsg->prefix_flags |= IF_PREFIX_AUTOCONF;
6152+
pmsg->prefix_flags = pinfo->flags;
61576153

61586154
if (nla_put(skb, PREFIX_ADDRESS, sizeof(pinfo->prefix), &pinfo->prefix))
61596155
goto nla_put_failure;

0 commit comments

Comments
 (0)