History

net: Get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID

Now that we have a dedicated NDO for getting a port's parent ID, get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID and convert all callers to use the NDO exclusively. This is a preliminary change to getting rid of switchdev_ops eventually.

Florian Fainelli committed 7 years ago

Commit bccb3021 parent 929d6c16 files · +15 −84Browse files

Unified · Split

6 files
  1. include/net/switchdev.h +0 −11
  2. net/bridge/br_switchdev.c +3 −11
  3. net/core/net-sysfs.c +4 −15
  4. net/core/rtnetlink.c +3 −13
  5. net/ipv4/ipmr.c +5 −14
  6. net/switchdev/switchdev.c +0 −20
include/net/switchdev.h+0−11
@@ -43,7 +43,6 @@ static inline bool switchdev_trans_ph_commit(struct switchdev_trans *trans) · 42 unmodified lines
4343
4444 enum switchdev_attr_id {
4545 SWITCHDEV_ATTR_ID_UNDEFINED,
46− SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
4746 SWITCHDEV_ATTR_ID_PORT_STP_STATE,
4847 SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
4948 SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
@@ -61,7 +60,6 @@ struct switchdev_attr { · 11 unmodified lines
6160 void *complete_priv;
6261 void (*complete)(struct net_device *dev, int err, void *priv);
6362 union {
64− struct netdev_phys_item_id ppid; /* PORT_PARENT_ID */
6563 u8 stp_state; /* PORT_STP_STATE */
6664 unsigned long brport_flags; /* PORT_BRIDGE_FLAGS */
6765 unsigned long brport_flags_support; /* PORT_BRIDGE_FLAGS_SUPPORT */
@@ -208,9 +206,6 @@ void switchdev_port_fwd_mark_set(struct net_device *dev, · 140 unmodified lines
208206 struct net_device *group_dev,
209207 bool joining);
210208
211−bool switchdev_port_same_parent_id(struct net_device *a,
212− struct net_device *b);
213−
214209 int switchdev_handle_port_obj_add(struct net_device *dev,
215210 struct switchdev_notifier_port_obj_info *port_obj_info,
216211 bool (*check_cb)(const struct net_device *dev),
@@ -295,12 +290,6 @@ call_switchdev_blocking_notifiers(unsigned long val, · 78 unmodified lines
295290 return NOTIFY_DONE;
296291 }
297292
298−static inline bool switchdev_port_same_parent_id(struct net_device *a,
299− struct net_device *b)
300−{
301− return false;
302−}
303−
304293 static inline int
305294 switchdev_handle_port_obj_add(struct net_device *dev,
306295 struct switchdev_notifier_port_obj_info *port_obj_info,
net/bridge/br_switchdev.c+3−11
@@ -14,8 +14,7 @@ static int br_switchdev_mark_get(struct net_bridge *br, struct net_device *dev) · 13 unmodified lines
1414
1515 /* dev is yet to be added to the port list. */
1616 list_for_each_entry(p, &br->port_list, list) {
17− if (netdev_port_same_parent_id(dev, p->dev) ||
18− switchdev_port_same_parent_id(dev, p->dev))
17+ if (netdev_port_same_parent_id(dev, p->dev))
1918 return p->offload_fwd_mark;
2019 }
2120
@@ -24,19 +23,12 @@ static int br_switchdev_mark_get(struct net_bridge *br, struct net_device *dev) · 2 unmodified lines
2423
2524 int nbp_switchdev_mark_set(struct net_bridge_port *p)
2625 {
27− const struct net_device_ops *ops = p->dev->netdev_ops;
28− struct switchdev_attr attr = {
29− .orig_dev = p->dev,
30− .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
31− };
26+ struct netdev_phys_item_id ppid = { };
3227 int err;
3328
3429 ASSERT_RTNL();
3530
36− if (ops->ndo_get_port_parent_id)
37− err = dev_get_port_parent_id(p->dev, &attr.u.ppid, true);
38− else
39− err = switchdev_port_attr_get(p->dev, &attr);
31+ err = dev_get_port_parent_id(p->dev, &ppid, true);
4032 if (err) {
4133 if (err == -EOPNOTSUPP)
4234 return 0;
net/core/net-sysfs.c+4−15
@@ -12,7 +12,6 @@ · 11 unmodified lines
1212 #include <linux/capability.h>
1313 #include <linux/kernel.h>
1414 #include <linux/netdevice.h>
15−#include <net/switchdev.h>
1615 #include <linux/if_arp.h>
1716 #include <linux/slab.h>
1817 #include <linux/sched/signal.h>
@@ -495,27 +494,17 @@ static ssize_t phys_switch_id_show(struct device *dev, · 476 unmodified lines
495494 struct device_attribute *attr, char *buf)
496495 {
497496 struct net_device *netdev = to_net_dev(dev);
498− const struct net_device_ops *ops = netdev->netdev_ops;
499497 ssize_t ret = -EINVAL;
500498
501499 if (!rtnl_trylock())
502500 return restart_syscall();
503501
504502 if (dev_isalive(netdev)) {
505− struct switchdev_attr attr = {
506− .orig_dev = netdev,
507− .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
508− .flags = SWITCHDEV_F_NO_RECURSE,
509− };
510−
511− if (ops->ndo_get_port_parent_id)
512− ret = dev_get_port_parent_id(netdev, &attr.u.ppid,
513− false);
514− else
515− ret = switchdev_port_attr_get(netdev, &attr);
503+ struct netdev_phys_item_id ppid = { };
504+
505+ ret = dev_get_port_parent_id(netdev, &ppid, false);
516506 if (!ret)
517− ret = sprintf(buf, "%*phN\n", attr.u.ppid.id_len,
518− attr.u.ppid.id);
507+ ret = sprintf(buf, "%*phN\n", ppid.id_len, ppid.id);
519508 }
520509 rtnl_unlock();
521510
net/core/rtnetlink.c+3−13
@@ -46,7 +46,6 @@ · 45 unmodified lines
4646
4747 #include <linux/inet.h>
4848 #include <linux/netdevice.h>
49−#include <net/switchdev.h>
5049 #include <net/ip.h>
5150 #include <net/protocol.h>
5251 #include <net/arp.h>
@@ -1146,26 +1145,17 @@ static int rtnl_phys_port_name_fill(struct sk_buff *skb, struct net_device *dev) · 1093 unmodified lines
11461145
11471146 static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev)
11481147 {
1149− const struct net_device_ops *ops = dev->netdev_ops;
1148+ struct netdev_phys_item_id ppid = { };
11501149 int err;
1151− struct switchdev_attr attr = {
1152− .orig_dev = dev,
1153− .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
1154− .flags = SWITCHDEV_F_NO_RECURSE,
1155− };
11561150
1157− if (ops->ndo_get_port_parent_id)
1158− err = dev_get_port_parent_id(dev, &attr.u.ppid, false);
1159− else
1160− err = switchdev_port_attr_get(dev, &attr);
1151+ err = dev_get_port_parent_id(dev, &ppid, false);
11611152 if (err) {
11621153 if (err == -EOPNOTSUPP)
11631154 return 0;
11641155 return err;
11651156 }
11661157
1167− if (nla_put(skb, IFLA_PHYS_SWITCH_ID, attr.u.ppid.id_len,
1168− attr.u.ppid.id))
1158+ if (nla_put(skb, IFLA_PHYS_SWITCH_ID, ppid.id_len, ppid.id))
11691159 return -EMSGSIZE;
11701160
11711161 return 0;
net/ipv4/ipmr.c+5−14
@@ -67,7 +67,6 @@ · 66 unmodified lines
6767 #include <net/fib_rules.h>
6868 #include <linux/netconf.h>
6969 #include <net/nexthop.h>
70−#include <net/switchdev.h>
7170
7271 #include <linux/nospec.h>
7372
@@ -837,11 +836,8 @@ static void ipmr_update_thresholds(struct mr_table *mrt, struct mr_mfc *cache, · 763 unmodified lines
837836 static int vif_add(struct net *net, struct mr_table *mrt,
838837 struct vifctl *vifc, int mrtsock)
839838 {
840− const struct net_device_ops *ops;
839+ struct netdev_phys_item_id ppid = { };
841840 int vifi = vifc->vifc_vifi;
842− struct switchdev_attr attr = {
843− .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
844− };
845841 struct vif_device *v = &mrt->vif_table[vifi];
846842 struct net_device *dev;
847843 struct in_device *in_dev;
@@ -920,15 +916,10 @@ static int vif_add(struct net *net, struct mr_table *mrt, · 72 unmodified lines
920916 vifc->vifc_flags | (!mrtsock ? VIFF_STATIC : 0),
921917 (VIFF_TUNNEL | VIFF_REGISTER));
922918
923− attr.orig_dev = dev;
924− ops = dev->netdev_ops;
925− if (ops->ndo_get_port_parent_id &&
926− !dev_get_port_parent_id(dev, &attr.u.ppid, true)) {
927− memcpy(v->dev_parent_id.id, attr.u.ppid.id, attr.u.ppid.id_len);
928− v->dev_parent_id.id_len = attr.u.ppid.id_len;
929− } else if (!switchdev_port_attr_get(dev, &attr)) {
930− memcpy(v->dev_parent_id.id, attr.u.ppid.id, attr.u.ppid.id_len);
931− v->dev_parent_id.id_len = attr.u.ppid.id_len;
919+ err = dev_get_port_parent_id(dev, &ppid, true);
920+ if (err == 0) {
921+ memcpy(v->dev_parent_id.id, ppid.id, ppid.id_len);
922+ v->dev_parent_id.id_len = ppid.id_len;
932923 } else {
933924 v->dev_parent_id.id_len = 0;
934925 }
net/switchdev/switchdev.c+0−20
@@ -592,26 +592,6 @@ int call_switchdev_blocking_notifiers(unsigned long val, struct net_device *dev, · 591 unmodified lines
592592 }
593593 EXPORT_SYMBOL_GPL(call_switchdev_blocking_notifiers);
594594
595−bool switchdev_port_same_parent_id(struct net_device *a,
596− struct net_device *b)
597−{
598− struct switchdev_attr a_attr = {
599− .orig_dev = a,
600− .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
601− };
602− struct switchdev_attr b_attr = {
603− .orig_dev = b,
604− .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID,
605− };
606−
607− if (switchdev_port_attr_get(a, &a_attr) ||
608− switchdev_port_attr_get(b, &b_attr))
609− return false;
610−
611− return netdev_phys_item_id_same(&a_attr.u.ppid, &b_attr.u.ppid);
612−}
613−EXPORT_SYMBOL_GPL(switchdev_port_same_parent_id);
614−
615595 static int __switchdev_handle_port_obj_add(struct net_device *dev,
616596 struct switchdev_notifier_port_obj_info *port_obj_info,
617597 bool (*check_cb)(const struct net_device *dev),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t