* [PATCH net-next] net: introduce IFF_NO_RX_HANDLER
@ 2018-03-09 9:39 Paolo Abeni
2018-03-09 18:00 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Abeni @ 2018-03-09 9:39 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Mahesh Bandewar, Jiri Benc
Some network devices - notably ipvlan slave - are not compatible with
any kind of rx_handler. Currently the hook can be installed but any
configuration (bridge, bond, macsec, ...) is nonfunctional.
This change allocates a priv_flag bit to mark such devices and explicitly
forbid installing a rx_handler if such bit is set. The new bit is used
by ipvlan slave device.
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
Notes:
- accocating a new bit instead of reusing old IFF_IPVLAN*, to allow
other driver leveraging it, if need arises
---
drivers/net/ipvlan/ipvlan_main.c | 2 ++
include/linux/netdevice.h | 3 +++
net/core/dev.c | 3 +++
3 files changed, 8 insertions(+)
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 23fd5ab180e8..743d37fb034a 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -604,6 +604,8 @@ int ipvlan_link_new(struct net *src_net, struct net_device *dev,
*/
memcpy(dev->dev_addr, phy_dev->dev_addr, ETH_ALEN);
+ dev->priv_flags |= IFF_NO_RX_HANDLER;
+
err = register_netdevice(dev);
if (err < 0)
return err;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 95a613a7cc1c..4f3d2a0e2ad6 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1390,6 +1390,7 @@ struct net_device_ops {
* @IFF_PHONY_HEADROOM: the headroom value is controlled by an external
* entity (i.e. the master device for bridged veth)
* @IFF_MACSEC: device is a MACsec device
+ * @IFF_NO_RX_HANDLER: device doesn't support the rx_handler hook
*/
enum netdev_priv_flags {
IFF_802_1Q_VLAN = 1<<0,
@@ -1418,6 +1419,7 @@ enum netdev_priv_flags {
IFF_RXFH_CONFIGURED = 1<<23,
IFF_PHONY_HEADROOM = 1<<24,
IFF_MACSEC = 1<<25,
+ IFF_NO_RX_HANDLER = 1<<26,
};
#define IFF_802_1Q_VLAN IFF_802_1Q_VLAN
@@ -1445,6 +1447,7 @@ enum netdev_priv_flags {
#define IFF_TEAM IFF_TEAM
#define IFF_RXFH_CONFIGURED IFF_RXFH_CONFIGURED
#define IFF_MACSEC IFF_MACSEC
+#define IFF_NO_RX_HANDLER IFF_NO_RX_HANDLER
/**
* struct net_device - The DEVICE structure.
diff --git a/net/core/dev.c b/net/core/dev.c
index e5b8d42b6410..259abb1515d0 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4351,6 +4351,9 @@ int netdev_rx_handler_register(struct net_device *dev,
if (netdev_is_rx_handler_busy(dev))
return -EBUSY;
+ if (dev->priv_flags & IFF_NO_RX_HANDLER)
+ return -EINVAL;
+
/* Note: rx_handler_data must be set before rx_handler */
rcu_assign_pointer(dev->rx_handler_data, rx_handler_data);
rcu_assign_pointer(dev->rx_handler, rx_handler);
--
2.14.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net: introduce IFF_NO_RX_HANDLER
2018-03-09 9:39 [PATCH net-next] net: introduce IFF_NO_RX_HANDLER Paolo Abeni
@ 2018-03-09 18:00 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-03-09 18:00 UTC (permalink / raw)
To: pabeni; +Cc: netdev, maheshb, jbenc
From: Paolo Abeni <pabeni@redhat.com>
Date: Fri, 9 Mar 2018 10:39:24 +0100
> Some network devices - notably ipvlan slave - are not compatible with
> any kind of rx_handler. Currently the hook can be installed but any
> configuration (bridge, bond, macsec, ...) is nonfunctional.
>
> This change allocates a priv_flag bit to mark such devices and explicitly
> forbid installing a rx_handler if such bit is set. The new bit is used
> by ipvlan slave device.
>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This looks fine, applied, thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-09 18:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-09 9:39 [PATCH net-next] net: introduce IFF_NO_RX_HANDLER Paolo Abeni
2018-03-09 18:00 ` 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).