net: Report dev->promiscuity in netlink reports.
authorBen Greear <greearb@candelatech.com>
Thu, 29 Mar 2012 12:51:30 +0000 (12:51 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 Apr 2012 08:33:46 +0000 (04:33 -0400)
The standard ways of probing a device's promiscuity
(ifi_flags, for instance) does not report the actual
state of the device.  This patch adds dev->promiscuity
to the netlink netdevice report so that users can know
for certain if the device is acting PROMISC or not.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/if_link.h
net/core/rtnetlink.c

index 4b24ff453aee56029a2b2e0b5ee233b9afab6977..2f4fa93454c7ec4ba1494a74838605a737e9fc13 100644 (file)
@@ -138,6 +138,8 @@ enum {
        IFLA_GROUP,             /* Group the device belongs to */
        IFLA_NET_NS_FD,
        IFLA_EXT_MASK,          /* Extended info mask, VFs, etc */
+       IFLA_PROMISCUITY,       /* Promiscuity count: > 0 means acts PROMISC */
+#define IFLA_PROMISCUITY IFLA_PROMISCUITY
        __IFLA_MAX
 };
 
index 71a1920a23a122e043e87ae262cecaba37285ec7..b76f8fa3fc64f2f2df1cf3d0419b562b30262e51 100644 (file)
@@ -784,6 +784,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
               + nla_total_size(4) /* IFLA_MTU */
               + nla_total_size(4) /* IFLA_LINK */
               + nla_total_size(4) /* IFLA_MASTER */
+              + nla_total_size(4) /* IFLA_PROMISCUITY */
               + nla_total_size(1) /* IFLA_OPERSTATE */
               + nla_total_size(1) /* IFLA_LINKMODE */
               + nla_total_size(ext_filter_mask
@@ -901,6 +902,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
            nla_put_u8(skb, IFLA_LINKMODE, dev->link_mode) ||
            nla_put_u32(skb, IFLA_MTU, dev->mtu) ||
            nla_put_u32(skb, IFLA_GROUP, dev->group) ||
+           nla_put_u32(skb, IFLA_PROMISCUITY, dev->promiscuity) ||
            (dev->ifindex != dev->iflink &&
             nla_put_u32(skb, IFLA_LINK, dev->iflink)) ||
            (dev->master &&
@@ -1117,6 +1119,7 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
        [IFLA_PORT_SELF]        = { .type = NLA_NESTED },
        [IFLA_AF_SPEC]          = { .type = NLA_NESTED },
        [IFLA_EXT_MASK]         = { .type = NLA_U32 },
+       [IFLA_PROMISCUITY]      = { .type = NLA_U32 },
 };
 EXPORT_SYMBOL(ifla_policy);