Skip to content

Commit 1ec54cb

Browse files
Paolo Abenidavem330
authored andcommitted
net: unpollute priv_flags space
the ipvlan device driver defines and uses 2 bits inside the priv_flags net_device field. Such bits and the related helper are used only inside the ipvlan device driver, and the core networking does not need to be aware of them. This change moves netif_is_ipvlan* helper in the ipvlan driver and re-implement them looking for ipvlan specific symbols instead of using priv_flags. Overall this frees two bits inside priv_flags - and move the following ones to avoid gaps - without any intended functional change. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b2b1949 commit 1ec54cb

File tree

3 files changed

+20
-28
lines changed

3 files changed

+20
-28
lines changed

drivers/net/ipvlan/ipvlan.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,10 @@ int ipvlan_link_new(struct net *src_net, struct net_device *dev,
177177
void ipvlan_link_delete(struct net_device *dev, struct list_head *head);
178178
void ipvlan_link_setup(struct net_device *dev);
179179
int ipvlan_link_register(struct rtnl_link_ops *ops);
180+
181+
static inline bool netif_is_ipvlan_port(const struct net_device *dev)
182+
{
183+
return dev->rx_handler == ipvlan_handle_frame;
184+
}
185+
180186
#endif /* __IPVLAN_H */

drivers/net/ipvlan/ipvlan_main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ static int ipvlan_port_create(struct net_device *dev)
129129
if (err)
130130
goto err;
131131

132-
dev->priv_flags |= IFF_IPVLAN_MASTER;
133132
return 0;
134133

135134
err:
@@ -142,7 +141,6 @@ static void ipvlan_port_destroy(struct net_device *dev)
142141
struct ipvl_port *port = ipvlan_port_get_rtnl(dev);
143142
struct sk_buff *skb;
144143

145-
dev->priv_flags &= ~IFF_IPVLAN_MASTER;
146144
if (port->mode == IPVLAN_MODE_L3S) {
147145
dev->priv_flags &= ~IFF_L3MDEV_MASTER;
148146
ipvlan_unregister_nf_hook(dev_net(dev));
@@ -423,6 +421,12 @@ static const struct header_ops ipvlan_header_ops = {
423421
.cache_update = eth_header_cache_update,
424422
};
425423

424+
static bool netif_is_ipvlan(const struct net_device *dev)
425+
{
426+
/* both ipvlan and ipvtap devices use the same netdev_ops */
427+
return dev->netdev_ops == &ipvlan_netdev_ops;
428+
}
429+
426430
static int ipvlan_ethtool_get_link_ksettings(struct net_device *dev,
427431
struct ethtool_link_ksettings *cmd)
428432
{
@@ -600,8 +604,6 @@ int ipvlan_link_new(struct net *src_net, struct net_device *dev,
600604
*/
601605
memcpy(dev->dev_addr, phy_dev->dev_addr, ETH_ALEN);
602606

603-
dev->priv_flags |= IFF_IPVLAN_SLAVE;
604-
605607
err = register_netdevice(dev);
606608
if (err < 0)
607609
return err;

include/linux/netdevice.h

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,8 +1381,6 @@ struct net_device_ops {
13811381
* @IFF_MACVLAN: Macvlan device
13821382
* @IFF_XMIT_DST_RELEASE_PERM: IFF_XMIT_DST_RELEASE not taking into account
13831383
* underlying stacked devices
1384-
* @IFF_IPVLAN_MASTER: IPvlan master device
1385-
* @IFF_IPVLAN_SLAVE: IPvlan slave device
13861384
* @IFF_L3MDEV_MASTER: device is an L3 master device
13871385
* @IFF_NO_QUEUE: device can run without qdisc attached
13881386
* @IFF_OPENVSWITCH: device is a Open vSwitch master
@@ -1412,16 +1410,14 @@ enum netdev_priv_flags {
14121410
IFF_LIVE_ADDR_CHANGE = 1<<15,
14131411
IFF_MACVLAN = 1<<16,
14141412
IFF_XMIT_DST_RELEASE_PERM = 1<<17,
1415-
IFF_IPVLAN_MASTER = 1<<18,
1416-
IFF_IPVLAN_SLAVE = 1<<19,
1417-
IFF_L3MDEV_MASTER = 1<<20,
1418-
IFF_NO_QUEUE = 1<<21,
1419-
IFF_OPENVSWITCH = 1<<22,
1420-
IFF_L3MDEV_SLAVE = 1<<23,
1421-
IFF_TEAM = 1<<24,
1422-
IFF_RXFH_CONFIGURED = 1<<25,
1423-
IFF_PHONY_HEADROOM = 1<<26,
1424-
IFF_MACSEC = 1<<27,
1413+
IFF_L3MDEV_MASTER = 1<<18,
1414+
IFF_NO_QUEUE = 1<<19,
1415+
IFF_OPENVSWITCH = 1<<20,
1416+
IFF_L3MDEV_SLAVE = 1<<21,
1417+
IFF_TEAM = 1<<22,
1418+
IFF_RXFH_CONFIGURED = 1<<23,
1419+
IFF_PHONY_HEADROOM = 1<<24,
1420+
IFF_MACSEC = 1<<25,
14251421
};
14261422

14271423
#define IFF_802_1Q_VLAN IFF_802_1Q_VLAN
@@ -1442,8 +1438,6 @@ enum netdev_priv_flags {
14421438
#define IFF_LIVE_ADDR_CHANGE IFF_LIVE_ADDR_CHANGE
14431439
#define IFF_MACVLAN IFF_MACVLAN
14441440
#define IFF_XMIT_DST_RELEASE_PERM IFF_XMIT_DST_RELEASE_PERM
1445-
#define IFF_IPVLAN_MASTER IFF_IPVLAN_MASTER
1446-
#define IFF_IPVLAN_SLAVE IFF_IPVLAN_SLAVE
14471441
#define IFF_L3MDEV_MASTER IFF_L3MDEV_MASTER
14481442
#define IFF_NO_QUEUE IFF_NO_QUEUE
14491443
#define IFF_OPENVSWITCH IFF_OPENVSWITCH
@@ -4223,16 +4217,6 @@ static inline bool netif_is_macvlan_port(const struct net_device *dev)
42234217
return dev->priv_flags & IFF_MACVLAN_PORT;
42244218
}
42254219

4226-
static inline bool netif_is_ipvlan(const struct net_device *dev)
4227-
{
4228-
return dev->priv_flags & IFF_IPVLAN_SLAVE;
4229-
}
4230-
4231-
static inline bool netif_is_ipvlan_port(const struct net_device *dev)
4232-
{
4233-
return dev->priv_flags & IFF_IPVLAN_MASTER;
4234-
}
4235-
42364220
static inline bool netif_is_bond_master(const struct net_device *dev)
42374221
{
42384222
return dev->flags & IFF_MASTER && dev->priv_flags & IFF_BONDING;

0 commit comments

Comments
 (0)