Skip to content

Commit 2106efd

Browse files
kuba-moodavem330
authored andcommitted
net: remove .ndo_change_proto_down
.ndo_change_proto_down was added seemingly to enable out-of-tree implementations. Over 2.5yrs later we still have no real users upstream. Hardwire the generic implementation for now, we can revert once real users materialize. (rocker is a test vehicle, not a user.) We need to drop the optimization on the sysfs side, because unlike ndos priv_flags will be changed at runtime, so we'd need READ_ONCE/WRITE_ONCE everywhere.. Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c384cee commit 2106efd

File tree

8 files changed

+11
-58
lines changed

8 files changed

+11
-58
lines changed

drivers/net/ethernet/rocker/rocker_main.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,17 +1995,6 @@ static int rocker_port_get_phys_port_name(struct net_device *dev,
19951995
return err ? -EOPNOTSUPP : 0;
19961996
}
19971997

1998-
static int rocker_port_change_proto_down(struct net_device *dev,
1999-
bool proto_down)
2000-
{
2001-
struct rocker_port *rocker_port = netdev_priv(dev);
2002-
2003-
if (rocker_port->dev->flags & IFF_UP)
2004-
rocker_port_set_enable(rocker_port, !proto_down);
2005-
rocker_port->dev->proto_down = proto_down;
2006-
return 0;
2007-
}
2008-
20091998
static void rocker_port_neigh_destroy(struct net_device *dev,
20101999
struct neighbour *n)
20112000
{
@@ -2037,7 +2026,6 @@ static const struct net_device_ops rocker_port_netdev_ops = {
20372026
.ndo_set_mac_address = rocker_port_set_mac_address,
20382027
.ndo_change_mtu = rocker_port_change_mtu,
20392028
.ndo_get_phys_port_name = rocker_port_get_phys_port_name,
2040-
.ndo_change_proto_down = rocker_port_change_proto_down,
20412029
.ndo_neigh_destroy = rocker_port_neigh_destroy,
20422030
.ndo_get_port_parent_id = rocker_port_get_port_parent_id,
20432031
};

drivers/net/macvlan.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,6 @@ static const struct net_device_ops macvlan_netdev_ops = {
11711171
#endif
11721172
.ndo_get_iflink = macvlan_dev_get_iflink,
11731173
.ndo_features_check = passthru_features_check,
1174-
.ndo_change_proto_down = dev_change_proto_down_generic,
11751174
};
11761175

11771176
void macvlan_common_setup(struct net_device *dev)
@@ -1182,7 +1181,7 @@ void macvlan_common_setup(struct net_device *dev)
11821181
dev->max_mtu = ETH_MAX_MTU;
11831182
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
11841183
netif_keep_dst(dev);
1185-
dev->priv_flags |= IFF_UNICAST_FLT;
1184+
dev->priv_flags |= IFF_UNICAST_FLT | IFF_CHANGE_PROTO_DOWN;
11861185
dev->netdev_ops = &macvlan_netdev_ops;
11871186
dev->needs_free_netdev = true;
11881187
dev->header_ops = &macvlan_hard_header_ops;

drivers/net/vxlan.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3234,7 +3234,6 @@ static const struct net_device_ops vxlan_netdev_ether_ops = {
32343234
.ndo_fdb_dump = vxlan_fdb_dump,
32353235
.ndo_fdb_get = vxlan_fdb_get,
32363236
.ndo_fill_metadata_dst = vxlan_fill_metadata_dst,
3237-
.ndo_change_proto_down = dev_change_proto_down_generic,
32383237
};
32393238

32403239
static const struct net_device_ops vxlan_netdev_raw_ops = {
@@ -3305,7 +3304,7 @@ static void vxlan_setup(struct net_device *dev)
33053304
dev->hw_features |= NETIF_F_RXCSUM;
33063305
dev->hw_features |= NETIF_F_GSO_SOFTWARE;
33073306
netif_keep_dst(dev);
3308-
dev->priv_flags |= IFF_NO_QUEUE;
3307+
dev->priv_flags |= IFF_NO_QUEUE | IFF_CHANGE_PROTO_DOWN;
33093308

33103309
/* MTU range: 68 - 65535 */
33113310
dev->min_mtu = ETH_MIN_MTU;

include/linux/netdevice.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,11 +1297,6 @@ struct netdev_net_notifier {
12971297
* TX queue.
12981298
* int (*ndo_get_iflink)(const struct net_device *dev);
12991299
* Called to get the iflink value of this device.
1300-
* void (*ndo_change_proto_down)(struct net_device *dev,
1301-
* bool proto_down);
1302-
* This function is used to pass protocol port error state information
1303-
* to the switch driver. The switch driver can react to the proto_down
1304-
* by doing a phys down on the associated switch port.
13051300
* int (*ndo_fill_metadata_dst)(struct net_device *dev, struct sk_buff *skb);
13061301
* This function is used to get egress tunnel information for given skb.
13071302
* This is useful for retrieving outer tunnel header parameters while
@@ -1542,8 +1537,6 @@ struct net_device_ops {
15421537
int queue_index,
15431538
u32 maxrate);
15441539
int (*ndo_get_iflink)(const struct net_device *dev);
1545-
int (*ndo_change_proto_down)(struct net_device *dev,
1546-
bool proto_down);
15471540
int (*ndo_fill_metadata_dst)(struct net_device *dev,
15481541
struct sk_buff *skb);
15491542
void (*ndo_set_rx_headroom)(struct net_device *dev,
@@ -1612,6 +1605,7 @@ struct net_device_ops {
16121605
* @IFF_LIVE_RENAME_OK: rename is allowed while device is up and running
16131606
* @IFF_TX_SKB_NO_LINEAR: device/driver is capable of xmitting frames with
16141607
* skb_headlen(skb) == 0 (data starts from frag0)
1608+
* @IFF_CHANGE_PROTO_DOWN: device supports setting carrier via IFLA_PROTO_DOWN
16151609
*/
16161610
enum netdev_priv_flags {
16171611
IFF_802_1Q_VLAN = 1<<0,
@@ -1646,6 +1640,7 @@ enum netdev_priv_flags {
16461640
IFF_L3MDEV_RX_HANDLER = 1<<29,
16471641
IFF_LIVE_RENAME_OK = 1<<30,
16481642
IFF_TX_SKB_NO_LINEAR = 1<<31,
1643+
IFF_CHANGE_PROTO_DOWN = BIT_ULL(32),
16491644
};
16501645

16511646
#define IFF_802_1Q_VLAN IFF_802_1Q_VLAN
@@ -1982,7 +1977,7 @@ struct net_device {
19821977

19831978
/* Read-mostly cache-line for fast-path access */
19841979
unsigned int flags;
1985-
unsigned int priv_flags;
1980+
unsigned long long priv_flags;
19861981
const struct net_device_ops *netdev_ops;
19871982
int ifindex;
19881983
unsigned short gflags;
@@ -3735,7 +3730,6 @@ int dev_get_port_parent_id(struct net_device *dev,
37353730
struct netdev_phys_item_id *ppid, bool recurse);
37363731
bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b);
37373732
int dev_change_proto_down(struct net_device *dev, bool proto_down);
3738-
int dev_change_proto_down_generic(struct net_device *dev, bool proto_down);
37393733
void dev_change_proto_down_reason(struct net_device *dev, unsigned long mask,
37403734
u32 value);
37413735
struct sk_buff *validate_xmit_skb_list(struct sk_buff *skb, struct net_device *dev, bool *again);

net/8021q/vlanproc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
252252

253253
stats = dev_get_stats(vlandev, &temp);
254254
seq_printf(seq,
255-
"%s VID: %d REORDER_HDR: %i dev->priv_flags: %hx\n",
255+
"%s VID: %d REORDER_HDR: %i dev->priv_flags: %llx\n",
256256
vlandev->name, vlan->vlan_id,
257257
(int)(vlan->flags & 1), vlandev->priv_flags);
258258

net/core/dev.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8558,43 +8558,25 @@ bool netdev_port_same_parent_id(struct net_device *a, struct net_device *b)
85588558
EXPORT_SYMBOL(netdev_port_same_parent_id);
85598559

85608560
/**
8561-
* dev_change_proto_down - update protocol port state information
8561+
* dev_change_proto_down - set carrier according to proto_down.
8562+
*
85628563
* @dev: device
85638564
* @proto_down: new value
8564-
*
8565-
* This info can be used by switch drivers to set the phys state of the
8566-
* port.
85678565
*/
85688566
int dev_change_proto_down(struct net_device *dev, bool proto_down)
85698567
{
8570-
const struct net_device_ops *ops = dev->netdev_ops;
8571-
8572-
if (!ops->ndo_change_proto_down)
8568+
if (!(dev->priv_flags & IFF_CHANGE_PROTO_DOWN))
85738569
return -EOPNOTSUPP;
85748570
if (!netif_device_present(dev))
85758571
return -ENODEV;
8576-
return ops->ndo_change_proto_down(dev, proto_down);
8577-
}
8578-
EXPORT_SYMBOL(dev_change_proto_down);
8579-
8580-
/**
8581-
* dev_change_proto_down_generic - generic implementation for
8582-
* ndo_change_proto_down that sets carrier according to
8583-
* proto_down.
8584-
*
8585-
* @dev: device
8586-
* @proto_down: new value
8587-
*/
8588-
int dev_change_proto_down_generic(struct net_device *dev, bool proto_down)
8589-
{
85908572
if (proto_down)
85918573
netif_carrier_off(dev);
85928574
else
85938575
netif_carrier_on(dev);
85948576
dev->proto_down = proto_down;
85958577
return 0;
85968578
}
8597-
EXPORT_SYMBOL(dev_change_proto_down_generic);
8579+
EXPORT_SYMBOL(dev_change_proto_down);
85988580

85998581
/**
86008582
* dev_change_proto_down_reason - proto down reason

net/core/net-sysfs.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,14 +488,6 @@ static ssize_t proto_down_store(struct device *dev,
488488
struct device_attribute *attr,
489489
const char *buf, size_t len)
490490
{
491-
struct net_device *netdev = to_net_dev(dev);
492-
493-
/* The check is also done in change_proto_down; this helps returning
494-
* early without hitting the trylock/restart in netdev_store.
495-
*/
496-
if (!netdev->netdev_ops->ndo_change_proto_down)
497-
return -EOPNOTSUPP;
498-
499491
return netdev_store(dev, attr, buf, len, change_proto_down);
500492
}
501493
NETDEVICE_SHOW_RW(proto_down, fmt_dec);

net/core/rtnetlink.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2539,13 +2539,12 @@ static int do_set_proto_down(struct net_device *dev,
25392539
struct netlink_ext_ack *extack)
25402540
{
25412541
struct nlattr *pdreason[IFLA_PROTO_DOWN_REASON_MAX + 1];
2542-
const struct net_device_ops *ops = dev->netdev_ops;
25432542
unsigned long mask = 0;
25442543
u32 value;
25452544
bool proto_down;
25462545
int err;
25472546

2548-
if (!ops->ndo_change_proto_down) {
2547+
if (!(dev->priv_flags & IFF_CHANGE_PROTO_DOWN)) {
25492548
NL_SET_ERR_MSG(extack, "Protodown not supported by device");
25502549
return -EOPNOTSUPP;
25512550
}

0 commit comments

Comments
 (0)