diff options
| -rw-r--r-- | include/uapi/linux/if_link.h | 1 | ||||
| -rw-r--r-- | net/core/rtnetlink.c | 26 |
2 files changed, 26 insertions, 1 deletions
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index 36bddc233633..623f1a7c7627 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h | |||
| @@ -145,6 +145,7 @@ enum { | |||
| 145 | IFLA_CARRIER, | 145 | IFLA_CARRIER, |
| 146 | IFLA_PHYS_PORT_ID, | 146 | IFLA_PHYS_PORT_ID, |
| 147 | IFLA_CARRIER_CHANGES, | 147 | IFLA_CARRIER_CHANGES, |
| 148 | IFLA_PHYS_SWITCH_ID, | ||
| 148 | __IFLA_MAX | 149 | __IFLA_MAX |
| 149 | }; | 150 | }; |
| 150 | 151 | ||
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 0640f1fbe9dd..aa5cd2c53a56 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | 44 | ||
| 45 | #include <linux/inet.h> | 45 | #include <linux/inet.h> |
| 46 | #include <linux/netdevice.h> | 46 | #include <linux/netdevice.h> |
| 47 | #include <net/switchdev.h> | ||
| 47 | #include <net/ip.h> | 48 | #include <net/ip.h> |
| 48 | #include <net/protocol.h> | 49 | #include <net/protocol.h> |
| 49 | #include <net/arp.h> | 50 | #include <net/arp.h> |
| @@ -869,7 +870,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, | |||
| 869 | + rtnl_port_size(dev, ext_filter_mask) /* IFLA_VF_PORTS + IFLA_PORT_SELF */ | 870 | + rtnl_port_size(dev, ext_filter_mask) /* IFLA_VF_PORTS + IFLA_PORT_SELF */ |
| 870 | + rtnl_link_get_size(dev) /* IFLA_LINKINFO */ | 871 | + rtnl_link_get_size(dev) /* IFLA_LINKINFO */ |
| 871 | + rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */ | 872 | + rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */ |
| 872 | + nla_total_size(MAX_PHYS_ITEM_ID_LEN); /* IFLA_PHYS_PORT_ID */ | 873 | + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_PORT_ID */ |
| 874 | + nla_total_size(MAX_PHYS_ITEM_ID_LEN); /* IFLA_PHYS_SWITCH_ID */ | ||
| 873 | } | 875 | } |
| 874 | 876 | ||
| 875 | static int rtnl_vf_ports_fill(struct sk_buff *skb, struct net_device *dev) | 877 | static int rtnl_vf_ports_fill(struct sk_buff *skb, struct net_device *dev) |
| @@ -968,6 +970,24 @@ static int rtnl_phys_port_id_fill(struct sk_buff *skb, struct net_device *dev) | |||
| 968 | return 0; | 970 | return 0; |
| 969 | } | 971 | } |
| 970 | 972 | ||
| 973 | static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev) | ||
| 974 | { | ||
| 975 | int err; | ||
| 976 | struct netdev_phys_item_id psid; | ||
| 977 | |||
| 978 | err = netdev_switch_parent_id_get(dev, &psid); | ||
| 979 | if (err) { | ||
| 980 | if (err == -EOPNOTSUPP) | ||
| 981 | return 0; | ||
| 982 | return err; | ||
| 983 | } | ||
| 984 | |||
| 985 | if (nla_put(skb, IFLA_PHYS_SWITCH_ID, psid.id_len, psid.id)) | ||
| 986 | return -EMSGSIZE; | ||
| 987 | |||
| 988 | return 0; | ||
| 989 | } | ||
| 990 | |||
| 971 | static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, | 991 | static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, |
| 972 | int type, u32 pid, u32 seq, u32 change, | 992 | int type, u32 pid, u32 seq, u32 change, |
| 973 | unsigned int flags, u32 ext_filter_mask) | 993 | unsigned int flags, u32 ext_filter_mask) |
| @@ -1040,6 +1060,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, | |||
| 1040 | if (rtnl_phys_port_id_fill(skb, dev)) | 1060 | if (rtnl_phys_port_id_fill(skb, dev)) |
| 1041 | goto nla_put_failure; | 1061 | goto nla_put_failure; |
| 1042 | 1062 | ||
| 1063 | if (rtnl_phys_switch_id_fill(skb, dev)) | ||
| 1064 | goto nla_put_failure; | ||
| 1065 | |||
| 1043 | attr = nla_reserve(skb, IFLA_STATS, | 1066 | attr = nla_reserve(skb, IFLA_STATS, |
| 1044 | sizeof(struct rtnl_link_stats)); | 1067 | sizeof(struct rtnl_link_stats)); |
| 1045 | if (attr == NULL) | 1068 | if (attr == NULL) |
| @@ -1199,6 +1222,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { | |||
| 1199 | [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 }, | 1222 | [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 }, |
| 1200 | [IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN }, | 1223 | [IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN }, |
| 1201 | [IFLA_CARRIER_CHANGES] = { .type = NLA_U32 }, /* ignored */ | 1224 | [IFLA_CARRIER_CHANGES] = { .type = NLA_U32 }, /* ignored */ |
| 1225 | [IFLA_PHYS_SWITCH_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN }, | ||
| 1202 | }; | 1226 | }; |
| 1203 | 1227 | ||
| 1204 | static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { | 1228 | static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { |
