Skip to content

Commit edbc0bb

Browse files
greearbdavem330
authored andcommitted
net: Report dev->promiscuity in netlink reports.
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e4422b2 commit edbc0bb

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

include/linux/if_link.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ enum {
138138
IFLA_GROUP, /* Group the device belongs to */
139139
IFLA_NET_NS_FD,
140140
IFLA_EXT_MASK, /* Extended info mask, VFs, etc */
141+
IFLA_PROMISCUITY, /* Promiscuity count: > 0 means acts PROMISC */
142+
#define IFLA_PROMISCUITY IFLA_PROMISCUITY
141143
__IFLA_MAX
142144
};
143145

net/core/rtnetlink.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
784784
+ nla_total_size(4) /* IFLA_MTU */
785785
+ nla_total_size(4) /* IFLA_LINK */
786786
+ nla_total_size(4) /* IFLA_MASTER */
787+
+ nla_total_size(4) /* IFLA_PROMISCUITY */
787788
+ nla_total_size(1) /* IFLA_OPERSTATE */
788789
+ nla_total_size(1) /* IFLA_LINKMODE */
789790
+ nla_total_size(ext_filter_mask
@@ -901,6 +902,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
901902
nla_put_u8(skb, IFLA_LINKMODE, dev->link_mode) ||
902903
nla_put_u32(skb, IFLA_MTU, dev->mtu) ||
903904
nla_put_u32(skb, IFLA_GROUP, dev->group) ||
905+
nla_put_u32(skb, IFLA_PROMISCUITY, dev->promiscuity) ||
904906
(dev->ifindex != dev->iflink &&
905907
nla_put_u32(skb, IFLA_LINK, dev->iflink)) ||
906908
(dev->master &&
@@ -1117,6 +1119,7 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
11171119
[IFLA_PORT_SELF] = { .type = NLA_NESTED },
11181120
[IFLA_AF_SPEC] = { .type = NLA_NESTED },
11191121
[IFLA_EXT_MASK] = { .type = NLA_U32 },
1122+
[IFLA_PROMISCUITY] = { .type = NLA_U32 },
11201123
};
11211124
EXPORT_SYMBOL(ifla_policy);
11221125

0 commit comments

Comments
 (0)