ipv4: add support for IFA_FLAGS nl attribute
authorJiri Pirko <jiri@resnulli.us>
Sun, 8 Dec 2013 11:16:10 +0000 (12:16 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 11 Dec 2013 02:50:00 +0000 (21:50 -0500)
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/inetdevice.h
net/ipv4/devinet.c

index ae174ca565c9c6452aca44dca2a96669a59dd0d2..562e5c7c5d35527dc7c3fb47dbeb59aa1470b421 100644 (file)
@@ -136,8 +136,8 @@ struct in_ifaddr {
        __be32                  ifa_mask;
        __be32                  ifa_broadcast;
        unsigned char           ifa_scope;
-       unsigned char           ifa_flags;
        unsigned char           ifa_prefixlen;
+       __u32                   ifa_flags;
        char                    ifa_label[IFNAMSIZ];
 
        /* In seconds, relative to tstamp. Expiry is at tstamp + HZ * lft. */
index 43065be363010b3f9bd2c6bb0f65454931a32949..6f49efc9d4b72a9eb72656baddfbeeadbefc0d87 100644 (file)
@@ -99,6 +99,7 @@ static const struct nla_policy ifa_ipv4_policy[IFA_MAX+1] = {
        [IFA_BROADCAST]         = { .type = NLA_U32 },
        [IFA_LABEL]             = { .type = NLA_STRING, .len = IFNAMSIZ - 1 },
        [IFA_CACHEINFO]         = { .len = sizeof(struct ifa_cacheinfo) },
+       [IFA_FLAGS]             = { .type = NLA_U32 },
 };
 
 #define IN4_ADDR_HSIZE_SHIFT   8
@@ -757,7 +758,8 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
        INIT_HLIST_NODE(&ifa->hash);
        ifa->ifa_prefixlen = ifm->ifa_prefixlen;
        ifa->ifa_mask = inet_make_mask(ifm->ifa_prefixlen);
-       ifa->ifa_flags = ifm->ifa_flags;
+       ifa->ifa_flags = tb[IFA_FLAGS] ? nla_get_u32(tb[IFA_FLAGS]) :
+                                        ifm->ifa_flags;
        ifa->ifa_scope = ifm->ifa_scope;
        ifa->ifa_dev = in_dev;
 
@@ -1437,7 +1439,8 @@ static size_t inet_nlmsg_size(void)
               + nla_total_size(4) /* IFA_ADDRESS */
               + nla_total_size(4) /* IFA_LOCAL */
               + nla_total_size(4) /* IFA_BROADCAST */
-              + nla_total_size(IFNAMSIZ); /* IFA_LABEL */
+              + nla_total_size(IFNAMSIZ) /* IFA_LABEL */
+              + nla_total_size(4);  /* IFA_FLAGS */
 }
 
 static inline u32 cstamp_delta(unsigned long cstamp)
@@ -1505,6 +1508,7 @@ static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa,
             nla_put_be32(skb, IFA_BROADCAST, ifa->ifa_broadcast)) ||
            (ifa->ifa_label[0] &&
             nla_put_string(skb, IFA_LABEL, ifa->ifa_label)) ||
+           nla_put_u32(skb, IFA_FLAGS, ifa->ifa_flags) ||
            put_cacheinfo(skb, ifa->ifa_cstamp, ifa->ifa_tstamp,
                          preferred, valid))
                goto nla_put_failure;