All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next] macvlan: judge ACCEPT_LOCAL before broadcast
@ 2021-12-03  7:25 cgel.zte
  2021-12-04  3:13   ` kernel test robot
  0 siblings, 1 reply; 3+ messages in thread
From: cgel.zte @ 2021-12-03  7:25 UTC (permalink / raw)
  To: davem; +Cc: kuba, netdev, linux-kernel, Zhang Yunkai

From: Zhang Yunkai <zhang.yunkai@zte.com.cn>

When macvlan send broadcast,it need judge accept_local.If you don’t do
this, it will be received in the same namespace and treated as an
invalid source address.If open log_martians,it will also print an error
like this:
IPv4: martian source 173.254.95.16 from 173.254.100.109,
on dev eth0
ll header: 00000000: ff ff ff ff ff ff 40 00 ad fe 64 6d
08 06        ......@...dm..
IPv4: martian source 173.254.95.16 from 173.254.100.109,
on dev eth1
ll header: 00000000: ff ff ff ff ff ff 40 00 ad fe 64 6d
08 06        ......@...dm..

Modify the sender, or modify the receiver, or modify the printing error,
this is not an invalid source address, or it is clearly stated in the
RFC1812 whether this is an invalid source address.

Signed-off-by: Zhang Yunkai <zhang.yunkai@zte.com.cn>
---
 drivers/net/macvlan.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index d2f830ec2969..3a16139e7b47 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -19,6 +19,7 @@
 #include <linux/rculist.h>
 #include <linux/notifier.h>
 #include <linux/netdevice.h>
+#include <linux/inetdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/net_tstamp.h>
 #include <linux/ethtool.h>
@@ -268,6 +269,7 @@ static void macvlan_broadcast(struct sk_buff *skb,
 	unsigned int i;
 	int err;
 	unsigned int hash;
+	struct in_device *in_dev;
 
 	if (skb->protocol == htons(ETH_P_PAUSE))
 		return;
@@ -280,6 +282,18 @@ static void macvlan_broadcast(struct sk_buff *skb,
 		if (!test_bit(hash, vlan->mc_filter))
 			continue;
 
+		rcu_read_lock();
+		if (src && net_eq(dev_net(vlan->dev), dev_net(src))) {
+			in_dev = __in_dev_get_rcu(src);
+			if (!IN_DEV_ACCEPT_LOCAL(in_dev)) {
+				in_dev_put(in_dev);
+				rcu_read_unlock();
+				continue;
+			}
+			in_dev_put(in_dev);
+		}
+		rcu_read_unlock();
+
 		err = NET_RX_DROP;
 		nskb = skb_clone(skb, GFP_ATOMIC);
 		if (likely(nskb))
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH linux-next] macvlan: judge ACCEPT_LOCAL before broadcast
  2021-12-03  7:25 [PATCH linux-next] macvlan: judge ACCEPT_LOCAL before broadcast cgel.zte
@ 2021-12-04  3:13   ` kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-12-04  3:13 UTC (permalink / raw)
  To: cgel.zte, davem; +Cc: kbuild-all, kuba, netdev, linux-kernel, Zhang Yunkai

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20211202]

url:    https://github.com/0day-ci/linux/commits/cgel-zte-gmail-com/macvlan-judge-ACCEPT_LOCAL-before-broadcast/20211203-152701
base:    9606f9efb1cec7f8f5912326f182fbfbcad34382
config: arm-randconfig-c002-20211203 (https://download.01.org/0day-ci/archive/20211204/202112041109.HnEJ2McL-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/05cf69fa8abf1b7a7016dc8ee1adada1f80809b8
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review cgel-zte-gmail-com/macvlan-judge-ACCEPT_LOCAL-before-broadcast/20211203-152701
        git checkout 05cf69fa8abf1b7a7016dc8ee1adada1f80809b8
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arm-linux-gnueabi-ld: drivers/net/macvlan.o: in function `macvlan_broadcast':
>> macvlan.c:(.text+0x24a4): undefined reference to `in_dev_finish_destroy'
>> arm-linux-gnueabi-ld: macvlan.c:(.text+0x2618): undefined reference to `in_dev_finish_destroy'

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH linux-next] macvlan: judge ACCEPT_LOCAL before broadcast
@ 2021-12-04  3:13   ` kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-12-04  3:13 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1706 bytes --]

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20211202]

url:    https://github.com/0day-ci/linux/commits/cgel-zte-gmail-com/macvlan-judge-ACCEPT_LOCAL-before-broadcast/20211203-152701
base:    9606f9efb1cec7f8f5912326f182fbfbcad34382
config: arm-randconfig-c002-20211203 (https://download.01.org/0day-ci/archive/20211204/202112041109.HnEJ2McL-lkp(a)intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/05cf69fa8abf1b7a7016dc8ee1adada1f80809b8
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review cgel-zte-gmail-com/macvlan-judge-ACCEPT_LOCAL-before-broadcast/20211203-152701
        git checkout 05cf69fa8abf1b7a7016dc8ee1adada1f80809b8
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arm-linux-gnueabi-ld: drivers/net/macvlan.o: in function `macvlan_broadcast':
>> macvlan.c:(.text+0x24a4): undefined reference to `in_dev_finish_destroy'
>> arm-linux-gnueabi-ld: macvlan.c:(.text+0x2618): undefined reference to `in_dev_finish_destroy'

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-04  3:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03  7:25 [PATCH linux-next] macvlan: judge ACCEPT_LOCAL before broadcast cgel.zte
2021-12-04  3:13 ` kernel test robot
2021-12-04  3:13   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.