diff options
Diffstat (limited to 'net')
| -rw-r--r-- | net/bridge/br_switchdev.c | 14 | ||||
| -rw-r--r-- | net/core/net-sysfs.c | 19 | ||||
| -rw-r--r-- | net/core/rtnetlink.c | 16 | ||||
| -rw-r--r-- | net/ipv4/ipmr.c | 19 | ||||
| -rw-r--r-- | net/switchdev/switchdev.c | 20 |
5 files changed, 15 insertions, 73 deletions
diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c index 06b0ae44585f..db9e8ab96d48 100644 --- a/net/bridge/br_switchdev.c +++ b/net/bridge/br_switchdev.c | |||
| @@ -14,8 +14,7 @@ static int br_switchdev_mark_get(struct net_bridge *br, struct net_device *dev) | |||
| 14 | 14 | ||
| 15 | /* dev is yet to be added to the port list. */ | 15 | /* dev is yet to be added to the port list. */ |
| 16 | list_for_each_entry(p, &br->port_list, list) { | 16 | list_for_each_entry(p, &br->port_list, list) { |
| 17 | if (netdev_port_same_parent_id(dev, p->dev) || | 17 | if (netdev_port_same_parent_id(dev, p->dev)) |
| 18 | switchdev_port_same_parent_id(dev, p->dev)) | ||
| 19 | return p->offload_fwd_mark; | 18 | return p->offload_fwd_mark; |
| 20 | } | 19 | } |
| 21 | 20 | ||
| @@ -24,19 +23,12 @@ static int br_switchdev_mark_get(struct net_bridge *br, struct net_device *dev) | |||
| 24 | 23 | ||
| 25 | int nbp_switchdev_mark_set(struct net_bridge_port *p) | 24 | int nbp_switchdev_mark_set(struct net_bridge_port *p) |
| 26 | { | 25 | { |
| 27 | const struct net_device_ops *ops = p->dev->netdev_ops; | 26 | struct netdev_phys_item_id ppid = { }; |
| 28 | struct switchdev_attr attr = { | ||
| 29 | .orig_dev = p->dev, | ||
| 30 | .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID, | ||
| 31 | }; | ||
| 32 | int err; | 27 | int err; |
| 33 | 28 | ||
| 34 | ASSERT_RTNL(); | 29 | ASSERT_RTNL(); |
| 35 | 30 | ||
| 36 | if (ops->ndo_get_port_parent_id) | 31 | err = dev_get_port_parent_id(p->dev, &ppid, true); |
| 37 | err = dev_get_port_parent_id(p->dev, &attr.u.ppid, true); | ||
| 38 | else | ||
| 39 | err = switchdev_port_attr_get(p->dev, &attr); | ||
| 40 | if (err) { | 32 | if (err) { |
| 41 | if (err == -EOPNOTSUPP) | 33 | if (err == -EOPNOTSUPP) |
| 42 | return 0; | 34 | return 0; |
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 4eace9f1dcf9..7c5061123ead 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include <linux/capability.h> | 12 | #include <linux/capability.h> |
| 13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
| 14 | #include <linux/netdevice.h> | 14 | #include <linux/netdevice.h> |
| 15 | #include <net/switchdev.h> | ||
| 16 | #include <linux/if_arp.h> | 15 | #include <linux/if_arp.h> |
| 17 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
| 18 | #include <linux/sched/signal.h> | 17 | #include <linux/sched/signal.h> |
| @@ -495,27 +494,17 @@ static ssize_t phys_switch_id_show(struct device *dev, | |||
| 495 | struct device_attribute *attr, char *buf) | 494 | struct device_attribute *attr, char *buf) |
| 496 | { | 495 | { |
| 497 | struct net_device *netdev = to_net_dev(dev); | 496 | struct net_device *netdev = to_net_dev(dev); |
| 498 | const struct net_device_ops *ops = netdev->netdev_ops; | ||
| 499 | ssize_t ret = -EINVAL; | 497 | ssize_t ret = -EINVAL; |
| 500 | 498 | ||
| 501 | if (!rtnl_trylock()) | 499 | if (!rtnl_trylock()) |
| 502 | return restart_syscall(); | 500 | return restart_syscall(); |
| 503 | 501 | ||
| 504 | if (dev_isalive(netdev)) { | 502 | if (dev_isalive(netdev)) { |
| 505 | struct switchdev_attr attr = { | 503 | struct netdev_phys_item_id ppid = { }; |
| 506 | .orig_dev = netdev, | 504 | |
| 507 | .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID, | 505 | ret = dev_get_port_parent_id(netdev, &ppid, false); |
| 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); | ||
| 516 | if (!ret) | 506 | if (!ret) |
| 517 | ret = sprintf(buf, "%*phN\n", attr.u.ppid.id_len, | 507 | ret = sprintf(buf, "%*phN\n", ppid.id_len, ppid.id); |
| 518 | attr.u.ppid.id); | ||
| 519 | } | 508 | } |
| 520 | rtnl_unlock(); | 509 | rtnl_unlock(); |
| 521 | 510 | ||
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 90dd02c1f561..a51cab95ba64 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
| @@ -46,7 +46,6 @@ | |||
| 46 | 46 | ||
| 47 | #include <linux/inet.h> | 47 | #include <linux/inet.h> |
| 48 | #include <linux/netdevice.h> | 48 | #include <linux/netdevice.h> |
| 49 | #include <net/switchdev.h> | ||
| 50 | #include <net/ip.h> | 49 | #include <net/ip.h> |
| 51 | #include <net/protocol.h> | 50 | #include <net/protocol.h> |
| 52 | #include <net/arp.h> | 51 | #include <net/arp.h> |
| @@ -1146,26 +1145,17 @@ static int rtnl_phys_port_name_fill(struct sk_buff *skb, struct net_device *dev) | |||
| 1146 | 1145 | ||
| 1147 | static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev) | 1146 | static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev) |
| 1148 | { | 1147 | { |
| 1149 | const struct net_device_ops *ops = dev->netdev_ops; | 1148 | struct netdev_phys_item_id ppid = { }; |
| 1150 | int err; | 1149 | 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 | }; | ||
| 1156 | 1150 | ||
| 1157 | if (ops->ndo_get_port_parent_id) | 1151 | err = dev_get_port_parent_id(dev, &ppid, false); |
| 1158 | err = dev_get_port_parent_id(dev, &attr.u.ppid, false); | ||
| 1159 | else | ||
| 1160 | err = switchdev_port_attr_get(dev, &attr); | ||
| 1161 | if (err) { | 1152 | if (err) { |
| 1162 | if (err == -EOPNOTSUPP) | 1153 | if (err == -EOPNOTSUPP) |
| 1163 | return 0; | 1154 | return 0; |
| 1164 | return err; | 1155 | return err; |
| 1165 | } | 1156 | } |
| 1166 | 1157 | ||
| 1167 | if (nla_put(skb, IFLA_PHYS_SWITCH_ID, attr.u.ppid.id_len, | 1158 | if (nla_put(skb, IFLA_PHYS_SWITCH_ID, ppid.id_len, ppid.id)) |
| 1168 | attr.u.ppid.id)) | ||
| 1169 | return -EMSGSIZE; | 1159 | return -EMSGSIZE; |
| 1170 | 1160 | ||
| 1171 | return 0; | 1161 | return 0; |
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index c71bcc42d66d..e536970557dd 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
| @@ -67,7 +67,6 @@ | |||
| 67 | #include <net/fib_rules.h> | 67 | #include <net/fib_rules.h> |
| 68 | #include <linux/netconf.h> | 68 | #include <linux/netconf.h> |
| 69 | #include <net/nexthop.h> | 69 | #include <net/nexthop.h> |
| 70 | #include <net/switchdev.h> | ||
| 71 | 70 | ||
| 72 | #include <linux/nospec.h> | 71 | #include <linux/nospec.h> |
| 73 | 72 | ||
| @@ -837,11 +836,8 @@ static void ipmr_update_thresholds(struct mr_table *mrt, struct mr_mfc *cache, | |||
| 837 | static int vif_add(struct net *net, struct mr_table *mrt, | 836 | static int vif_add(struct net *net, struct mr_table *mrt, |
| 838 | struct vifctl *vifc, int mrtsock) | 837 | struct vifctl *vifc, int mrtsock) |
| 839 | { | 838 | { |
| 840 | const struct net_device_ops *ops; | 839 | struct netdev_phys_item_id ppid = { }; |
| 841 | int vifi = vifc->vifc_vifi; | 840 | int vifi = vifc->vifc_vifi; |
| 842 | struct switchdev_attr attr = { | ||
| 843 | .id = SWITCHDEV_ATTR_ID_PORT_PARENT_ID, | ||
| 844 | }; | ||
| 845 | struct vif_device *v = &mrt->vif_table[vifi]; | 841 | struct vif_device *v = &mrt->vif_table[vifi]; |
| 846 | struct net_device *dev; | 842 | struct net_device *dev; |
| 847 | struct in_device *in_dev; | 843 | struct in_device *in_dev; |
| @@ -920,15 +916,10 @@ static int vif_add(struct net *net, struct mr_table *mrt, | |||
| 920 | vifc->vifc_flags | (!mrtsock ? VIFF_STATIC : 0), | 916 | vifc->vifc_flags | (!mrtsock ? VIFF_STATIC : 0), |
| 921 | (VIFF_TUNNEL | VIFF_REGISTER)); | 917 | (VIFF_TUNNEL | VIFF_REGISTER)); |
| 922 | 918 | ||
| 923 | attr.orig_dev = dev; | 919 | err = dev_get_port_parent_id(dev, &ppid, true); |
| 924 | ops = dev->netdev_ops; | 920 | if (err == 0) { |
| 925 | if (ops->ndo_get_port_parent_id && | 921 | memcpy(v->dev_parent_id.id, ppid.id, ppid.id_len); |
| 926 | !dev_get_port_parent_id(dev, &attr.u.ppid, true)) { | 922 | v->dev_parent_id.id_len = ppid.id_len; |
| 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; | ||
| 932 | } else { | 923 | } else { |
| 933 | v->dev_parent_id.id_len = 0; | 924 | v->dev_parent_id.id_len = 0; |
| 934 | } | 925 | } |
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index cd78253de31d..7e1357db33d7 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c | |||
| @@ -592,26 +592,6 @@ int call_switchdev_blocking_notifiers(unsigned long val, struct net_device *dev, | |||
| 592 | } | 592 | } |
| 593 | EXPORT_SYMBOL_GPL(call_switchdev_blocking_notifiers); | 593 | EXPORT_SYMBOL_GPL(call_switchdev_blocking_notifiers); |
| 594 | 594 | ||
| 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 | |||
| 615 | static int __switchdev_handle_port_obj_add(struct net_device *dev, | 595 | static int __switchdev_handle_port_obj_add(struct net_device *dev, |
| 616 | struct switchdev_notifier_port_obj_info *port_obj_info, | 596 | struct switchdev_notifier_port_obj_info *port_obj_info, |
| 617 | bool (*check_cb)(const struct net_device *dev), | 597 | bool (*check_cb)(const struct net_device *dev), |
