* [PATCH] net: fix rtnetlink IFF_PROMISC and IFF_ALLMULTI handling
@ 2012-07-27 12:58 Jiri Benc
2012-07-27 20:46 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Benc @ 2012-07-27 12:58 UTC (permalink / raw)
To: netdev; +Cc: Max Matveev
When device flags are set using rtnetlink, IFF_PROMISC and IFF_ALLMULTI
flags are handled specially. Function dev_change_flags sets IFF_PROMISC and
IFF_ALLMULTI bits in dev->gflags according to the passed value but
do_setlink passes a result of rtnl_dev_combine_flags which takes those bits
from dev->flags.
This can be easily trigerred by doing:
tcpdump -i eth0 &
ip l s up eth0
ip sets IFF_UP flag in ifi_flags and ifi_change, which is combined with
IFF_PROMISC by rtnl_dev_combine_flags, causing __dev_change_flags to set
IFF_PROMISC in gflags.
Reported-by: Max Matveev <makc@redhat.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
---
net/core/rtnetlink.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -659,6 +659,12 @@ static void set_operstate(struct net_dev
}
}
+static unsigned int rtnl_dev_get_flags(const struct net_device *dev)
+{
+ return (dev->flags & ~(IFF_PROMISC | IFF_ALLMULTI)) |
+ (dev->gflags & (IFF_PROMISC | IFF_ALLMULTI));
+}
+
static unsigned int rtnl_dev_combine_flags(const struct net_device *dev,
const struct ifinfomsg *ifm)
{
@@ -667,7 +673,7 @@ static unsigned int rtnl_dev_combine_fla
/* bugwards compatibility: ifi_change == 0 is treated as ~0 */
if (ifm->ifi_change)
flags = (flags & ifm->ifi_change) |
- (dev->flags & ~ifm->ifi_change);
+ (rtnl_dev_get_flags(dev) & ~ifm->ifi_change);
return flags;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] net: fix rtnetlink IFF_PROMISC and IFF_ALLMULTI handling
2012-07-27 12:58 [PATCH] net: fix rtnetlink IFF_PROMISC and IFF_ALLMULTI handling Jiri Benc
@ 2012-07-27 20:46 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-07-27 20:46 UTC (permalink / raw)
To: jbenc; +Cc: netdev, makc
From: Jiri Benc <jbenc@redhat.com>
Date: Fri, 27 Jul 2012 14:58:22 +0200
> When device flags are set using rtnetlink, IFF_PROMISC and IFF_ALLMULTI
> flags are handled specially. Function dev_change_flags sets IFF_PROMISC and
> IFF_ALLMULTI bits in dev->gflags according to the passed value but
> do_setlink passes a result of rtnl_dev_combine_flags which takes those bits
> from dev->flags.
>
> This can be easily trigerred by doing:
>
> tcpdump -i eth0 &
> ip l s up eth0
>
> ip sets IFF_UP flag in ifi_flags and ifi_change, which is combined with
> IFF_PROMISC by rtnl_dev_combine_flags, causing __dev_change_flags to set
> IFF_PROMISC in gflags.
>
> Reported-by: Max Matveev <makc@redhat.com>
> Signed-off-by: Jiri Benc <jbenc@redhat.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-27 20:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-27 12:58 [PATCH] net: fix rtnetlink IFF_PROMISC and IFF_ALLMULTI handling Jiri Benc
2012-07-27 20:46 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).