include: update headers
Subsystems (2)
PATCH 1/3 include: update headers
--- include/linux/if_link.h | 1 + include/linux/net_namespace.h | 23 +++++++++++++++++++++++ include/linux/rtnetlink.h | 5 +++++ 3 files changed, 29 insertions(+) create mode 100644 include/linux/net_namespace.h
include/linux/if_link.h +1 -0
@@ -146,6 +146,7 @@ enum {IFLA_PHYS_PORT_ID ,IFLA_CARRIER_CHANGES ,IFLA_PHYS_SWITCH_ID , +IFLA_LINK_NETNSID , __IFLA_MAX };
include/linux/net_namespace.h new file +23 -0
@@ -0,0 +1,23 @@ +/* Copyright (c) 2015 6WIND S.A. +* Author: Nicolas Dichtel <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +*/ +#ifndef _LINUX_NET_NAMESPACE_H_ +#define _LINUX_NET_NAMESPACE_H_ + +/* Attributes of RTM_NEWNSID/RTM_GETNSID messages */ +enum { +NETNSA_NONE , +#define NETNSA_NSID_NOT_ASSIGNED -1 + NETNSA_NSID, +NETNSA_PID , +NETNSA_FD , + __NETNSA_MAX, +}; + +#define NETNSA_MAX (__NETNSA_MAX - 1) + +#endif /* _LINUX_NET_NAMESPACE_H_ */
include/linux/rtnetlink.h +5 -0
@@ -132,6 +132,11 @@ enum { RTM_GETMDB = 86,#define RTM_GETMDB RTM_GETMDB + RTM_NEWNSID = 88, +#define RTM_NEWNSID RTM_NEWNSID + RTM_GETNSID = 90, +#define RTM_GETNSID RTM_GETNSID + __RTM_MAX,#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) };
Signature · 1 line
2.2.2
PATCH 2/3 ipnetns: allow to get and set netns ids
The kernel now provides ids for peer netns. This patch implements a new command 'set' to assign an id.
When netns are listed, if an id is assigned, it is now displayed.
Example:
$ ip netns add foo $ ip netns set foo 1 $ ip netns foo (id: 1) init_net
--- include/libnetlink.h | 8 ++++ ip/ipnetns.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++- man/man8/ip-netns.8 | 14 +++++++ 3 files changed, 134 insertions(+), 1 deletion(-)
include/libnetlink.h +8 -0
@@ -158,6 +158,14 @@ extern int rtnl_from_file(FILE *, rtnl_filter_t handler,#define NDTA_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg))#endif +#ifndef NETNS_RTA +#define NETNS_RTA (r) \ + ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtgenmsg)))) +#endif +#ifndef NETNS_PAYLOAD +#define NETNS_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct rtgenmsg)) +#endif +/* User defined nlmsg_type which is used mostly for logging netlink * messages from dump file */ #define NLMSG_TSTAMP 15
ip/ipnetns.c +112 -1
153 lines not on this page · raw message
man/man8/ip-netns.8 +14 -0
@@ -20,6 +20,10 @@ ip-netns \- process network namespace management .I NETNSNAME .ti -8 +.BR "ip netns" " { " set " } " +.I NETNSNAME NETNSID + +.ti -8 .BR "ip netns identify" .RI "[ " PID " ]"
@@ -85,6 +89,16 @@ persists until it has no more users. ip netns delete may fail if the mount point is in use in another mount namespace. .TP +.B ip netns set NAME NETNSID - assign an id to a peer network namespace +.sp +This command assigns a id to a peer network namespace. This id is valid +only in the current network namespace. +This id will be used by the kernel in some netlink messages. If no id is +assigned when the kernel needs it, it will be automatically assigned by +the kernel. +Once it is assigned, it's not possible to change it. + +.TP .B ip netns identify [PID] - Report network namespaces names for process .sp This command walks through /var/run/netns and finds all the network
Signature · 1 line
2.2.2
PATCH 3/3 iplink: add support of IFLA_LINK_NETNSID attribute
In reply to Nicolas DichtelThis new attribute is now advertised by the kernel for x-netns interfaces. It's also possible to set it when an interface is created (and thus creating a x-netns interface with one single message).
Example:
$ ip netns add foo
$ ip netns add bar
$ ip -n foo netns set bar 15
$ ip -n foo link add ipip1 link-netnsid 15 type ipip remote 10.16.0.121 local 10.16.0.249
$ ip -n foo link ls ipip1
3: ipip1@NONE: <POINTOPOINT,NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default
link/ipip 10.16.0.249 peer 10.16.0.121 link-netnsid 15--- ip/ipaddress.c | 10 ++++++++++ ip/iplink.c | 10 ++++++++++ 2 files changed, 20 insertions(+)
ip/ipaddress.c +10 -0
@@ -28,6 +28,7 @@#include <linux/netdevice.h> #include <linux/if_arp.h> #include <linux/sockios.h> +#include <linux/net_namespace.h> #include "rt_names.h" #include "utils.h"
@@ -678,6 +679,15 @@ int print_linkinfo(const struct sockaddr_nl *who, } } +if (tb[IFLA_LINK_NETNSID ]) { +int id = *(int *)RTA_DATA (tb[IFLA_LINK_NETNSID ]); + +if (id >=0 ) +fprintf (fp," link-netnsid %d" , id); +else +fprintf (fp," link-netnsid unknown" ); + } +if (tb[IFLA_PROMISCUITY ] && show_details)fprintf (fp," promiscuity %u " , *(int *)RTA_DATA (tb[IFLA_PROMISCUITY ]));
ip/iplink.c +10 -0
@@ -72,6 +72,7 @@ void iplink_usage(void)fprintf (stderr," [ mtu MTU ]\n" );fprintf (stderr," [ netns PID ]\n" );fprintf (stderr," [ netns NAME ]\n" ); +fprintf (stderr," [ link-netnsid ID ]\n" );fprintf (stderr," [ alias NAME ]\n" );fprintf (stderr," [ vf NUM [ mac LLADDR ]\n" );fprintf (stderr," [ vlan VLANID [ qos VLAN-QOS ] ]\n" );
@@ -386,6 +387,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,int numtxqueues =-1 ;int numrxqueues =-1 ;int dev_index =0 ; +int link_netnsid =-1 ; *group =-1 ; ret = argc;
@@ -588,6 +590,14 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,addattr8 (&req->n,sizeof (*req),IFLA_INET6_ADDR_GEN_MODE , mode);addattr_nest_end (&req->n, afs6);addattr_nest_end (&req->n, afs); + }else if (matches (*argv,"link-netnsid" ) ==0 ) { +NEXT_ARG (); +if (link_netnsid !=-1 ) +duparg ("link-netnsid" , *argv); +if (get_integer (&link_netnsid, *argv,0 )) +invarg ("Invalid \"link-netnsid\" value\n" , *argv); +addattr32 (&req->n,sizeof (*req),IFLA_LINK_NETNSID , + link_netnsid); }else {if (strcmp (*argv,"dev" ) ==0 ) {NEXT_ARG ();
Signature · 1 line
2.2.2
Quoted 2 lines · Nicolas Dichtel
Signed-off-by Nicolas Dichtel <[email protected]>---
Please drop this series, I will send a v2.
PATCH v2 1/4 include: update headers
Copy from sanitized headers.
---
v2: took last headers from net-next
include/linux/if_link.h | 4 ++++ include/linux/neighbour.h | 1 + include/linux/net_namespace.h | 23 +++++++++++++++++++++++ include/linux/rtnetlink.h | 5 +++++ 4 files changed, 33 insertions(+) create mode 100644 include/linux/net_namespace.h
include/linux/if_link.h +4 -0
@@ -146,6 +146,7 @@ enum {IFLA_PHYS_PORT_ID ,IFLA_CARRIER_CHANGES ,IFLA_PHYS_SWITCH_ID , +IFLA_LINK_NETNSID , __IFLA_MAX };
@@ -368,6 +369,9 @@ enum {IFLA_VXLAN_UDP_CSUM ,IFLA_VXLAN_UDP_ZERO_CSUM6_TX ,IFLA_VXLAN_UDP_ZERO_CSUM6_RX , +IFLA_VXLAN_REMCSUM_TX , +IFLA_VXLAN_REMCSUM_RX , +IFLA_VXLAN_GBP , __IFLA_VXLAN_MAX };#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
include/linux/neighbour.h +1 -0
@@ -25,6 +25,7 @@ enum {NDA_VNI ,NDA_IFINDEX ,NDA_MASTER , +NDA_LINK_NETNSID , __NDA_MAX };
include/linux/net_namespace.h new file +23 -0
@@ -0,0 +1,23 @@ +/* Copyright (c) 2015 6WIND S.A. +* Author: Nicolas Dichtel <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +*/ +#ifndef _LINUX_NET_NAMESPACE_H_ +#define _LINUX_NET_NAMESPACE_H_ + +/* Attributes of RTM_NEWNSID/RTM_GETNSID messages */ +enum { +NETNSA_NONE , +#define NETNSA_NSID_NOT_ASSIGNED -1 + NETNSA_NSID, +NETNSA_PID , +NETNSA_FD , + __NETNSA_MAX, +}; + +#define NETNSA_MAX (__NETNSA_MAX - 1) + +#endif /* _LINUX_NET_NAMESPACE_H_ */
include/linux/rtnetlink.h +5 -0
@@ -132,6 +132,11 @@ enum { RTM_GETMDB = 86,#define RTM_GETMDB RTM_GETMDB + RTM_NEWNSID = 88, +#define RTM_NEWNSID RTM_NEWNSID + RTM_GETNSID = 90, +#define RTM_GETNSID RTM_GETNSID + __RTM_MAX,#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) };
Signature · 1 line
2.2.2
PATCH v2 2/4 ipnetns: allow to get and set netns ids
The kernel now provides ids for peer netns. This patch implements a new command 'set' to assign an id.
When netns are listed, if an id is assigned, it is now displayed.
Example:
$ ip netns add foo $ ip netns set foo 1 $ ip netns foo (id: 1) init_net
---
v2: no change
include/libnetlink.h | 8 ++++ ip/ipnetns.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++- man/man8/ip-netns.8 | 14 +++++++ 3 files changed, 134 insertions(+), 1 deletion(-)
include/libnetlink.h +8 -0
@@ -158,6 +158,14 @@ extern int rtnl_from_file(FILE *, rtnl_filter_t handler,#define NDTA_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg))#endif +#ifndef NETNS_RTA +#define NETNS_RTA (r) \ + ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtgenmsg)))) +#endif +#ifndef NETNS_PAYLOAD +#define NETNS_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct rtgenmsg)) +#endif +/* User defined nlmsg_type which is used mostly for logging netlink * messages from dump file */ #define NLMSG_TSTAMP 15
ip/ipnetns.c +112 -1
153 lines not on this page · raw message
man/man8/ip-netns.8 +14 -0
@@ -20,6 +20,10 @@ ip-netns \- process network namespace management .I NETNSNAME .ti -8 +.BR "ip netns" " { " set " } " +.I NETNSNAME NETNSID + +.ti -8 .BR "ip netns identify" .RI "[ " PID " ]"
@@ -85,6 +89,16 @@ persists until it has no more users. ip netns delete may fail if the mount point is in use in another mount namespace. .TP +.B ip netns set NAME NETNSID - assign an id to a peer network namespace +.sp +This command assigns a id to a peer network namespace. This id is valid +only in the current network namespace. +This id will be used by the kernel in some netlink messages. If no id is +assigned when the kernel needs it, it will be automatically assigned by +the kernel. +Once it is assigned, it's not possible to change it. + +.TP .B ip netns identify [PID] - Report network namespaces names for process .sp This command walks through /var/run/netns and finds all the network
Signature · 1 line
2.2.2
PATCH v2 3/4 iplink: add support of IFLA_LINK_NETNSID attribute
In reply to Nicolas DichtelThis new attribute is now advertised by the kernel for x-netns interfaces. It's also possible to set it when an interface is created (and thus creating a x-netns interface with one single message).
Example:
$ ip netns add foo
$ ip netns add bar
$ ip -n foo netns set bar 15
$ ip -n foo link add ipip1 link-netnsid 15 type ipip remote 10.16.0.121 local 10.16.0.249
$ ip -n foo link ls ipip1
3: ipip1@NONE: <POINTOPOINT,NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default
link/ipip 10.16.0.249 peer 10.16.0.121 link-netnsid 15---
v2: don't try to convert IFLA_LINK to the devname when IFLA_LINK_NETNSID is set
ip/ipaddress.c | 20 +++++++++++++++++--- ip/iplink.c | 10 ++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-)
ip/ipaddress.c +17 -3
@@ -28,6 +28,7 @@#include <linux/netdevice.h> #include <linux/if_arp.h> #include <linux/sockios.h> +#include <linux/net_namespace.h> #include "rt_names.h" #include "utils.h"
@@ -614,9 +615,13 @@ int print_linkinfo(const struct sockaddr_nl *who,if (iflink ==0 )fprintf (fp,"@NONE: " );else { -fprintf (fp,"@%s: " ,ll_idx_n2a (iflink, b1)); - m_flag =ll_index_to_flags (iflink); - m_flag = !(m_flag &IFF_UP ); +if (tb[IFLA_LINK_NETNSID ]) +fprintf (fp,"@if%d: " , iflink); +else { +fprintf (fp,"@%s: " ,ll_idx_n2a (iflink, b1)); + m_flag =ll_index_to_flags (iflink); + m_flag = !(m_flag &IFF_UP ); + } } }else {fprintf (fp,": " );
@@ -678,6 +683,15 @@ int print_linkinfo(const struct sockaddr_nl *who, } } +if (tb[IFLA_LINK_NETNSID ]) { +int id = *(int *)RTA_DATA (tb[IFLA_LINK_NETNSID ]); + +if (id >=0 ) +fprintf (fp," link-netnsid %d" , id); +else +fprintf (fp," link-netnsid unknown" ); + } +if (tb[IFLA_PROMISCUITY ] && show_details)fprintf (fp," promiscuity %u " , *(int *)RTA_DATA (tb[IFLA_PROMISCUITY ]));
ip/iplink.c +10 -0
@@ -72,6 +72,7 @@ void iplink_usage(void)fprintf (stderr," [ mtu MTU ]\n" );fprintf (stderr," [ netns PID ]\n" );fprintf (stderr," [ netns NAME ]\n" ); +fprintf (stderr," [ link-netnsid ID ]\n" );fprintf (stderr," [ alias NAME ]\n" );fprintf (stderr," [ vf NUM [ mac LLADDR ]\n" );fprintf (stderr," [ vlan VLANID [ qos VLAN-QOS ] ]\n" );
@@ -386,6 +387,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,int numtxqueues =-1 ;int numrxqueues =-1 ;int dev_index =0 ; +int link_netnsid =-1 ; *group =-1 ; ret = argc;
@@ -588,6 +590,14 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,addattr8 (&req->n,sizeof (*req),IFLA_INET6_ADDR_GEN_MODE , mode);addattr_nest_end (&req->n, afs6);addattr_nest_end (&req->n, afs); + }else if (matches (*argv,"link-netnsid" ) ==0 ) { +NEXT_ARG (); +if (link_netnsid !=-1 ) +duparg ("link-netnsid" , *argv); +if (get_integer (&link_netnsid, *argv,0 )) +invarg ("Invalid \"link-netnsid\" value\n" , *argv); +addattr32 (&req->n,sizeof (*req),IFLA_LINK_NETNSID , + link_netnsid); }else {if (strcmp (*argv,"dev" ) ==0 ) {NEXT_ARG ();
Signature · 1 line
2.2.2
PATCH v2 4/4 bridge/fdb: display link netns id
In reply to Nicolas DichtelWhen this attribute is set, it means that the i/o part of the related netdevice is in another netns.
---
v2: new in the series
bridge/fdb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
bridge/fdb.c +5 -1
@@ -131,12 +131,16 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)if (ifindex) {char ifname[IF_NAMESIZE ]; -if (if_indextoname (ifindex, ifname)) +if (!tb[NDA_LINK_NETNSID ] && +if_indextoname (ifindex, ifname))fprintf (fp,"via %s " , ifname);else fprintf (fp,"via ifindex %u " , ifindex); } } +if (tb[NDA_LINK_NETNSID ]) +fprintf (fp,"link-netnsid %d " , +rta_getattr_u32 (tb[NDA_LINK_NETNSID ]));if (show_stats && tb[NDA_CACHEINFO ]) {struct nda_cacheinfo *ci =RTA_DATA (tb[NDA_CACHEINFO ]);
Signature · 1 line
2.2.2
Quoted 5 lines · On Wed, 28 Jan 2015 15:15:47 +0100 Nicolas Dichtel <[email protected]>…
Copy from sanitized headers.
Signed-off-by Nicolas Dichtel <[email protected]>---
Quoted 8 lines
v2: took last headers from net-next
include/linux/if_link.h | 4 ++++ include/linux/neighbour.h | 1 + include/linux/net_namespace.h | 23 +++++++++++++++++++++++ include/linux/rtnetlink.h | 5 +++++ 4 files changed, 33 insertions(+) create mode 100644 include/linux/net_namespace.h
All kernel headers for iproute2 must come from the result of:
$ make headers_install
Please submit a patch to net-next which makes net_namespace.h (from include/uapi/linux/net_namespace.h) get correctly installed into usr/include/linux/net_namespace.h
The file is missing from include/uapi/linux/Kbuild
Quoted 17 lines · Stephen Hemminger
Quoted 5 lines · On Wed, 28 Jan 2015 15:15:47 +0100 Nicolas Dichtel <[email protected]>…
Copy from sanitized headers.
Signed-off-by Nicolas Dichtel <[email protected]>---
Quoted 8 lines
v2: took last headers from net-next
include/linux/if_link.h | 4 ++++ include/linux/neighbour.h | 1 + include/linux/net_namespace.h | 23 +++++++++++++++++++++++ include/linux/rtnetlink.h | 5 +++++ 4 files changed, 33 insertions(+)create mode 100644
include/linux/net_namespace.h
Quoted 2 lines
All kernel headers for iproute2 must come from the result of:
$ make headers_install
I've done this.
Quoted 6 lines
Please submit a patch to net-next which makes
net_namespace.h(frominclude/uapi/linux/net_namespace.h) get correctly installed intousr/include/linux/net_namespace.hThe file is missing from
include/uapi/linux/Kbuild
Hmm, I'm probably missing something (with net-next):
$ git grep net_namespace.h include/uapi/linux/Kbuild include/uapi/linux/Kbuild:header-y += net_namespace.h $ rm -rf usr/include/ $ make headers_install $ find usr/include/ -name net_namespace.h usr/include/linux/net_namespace.h
PATCH v3 1/4 include: update headers
Copy from sanitized headers.
---
v3: rebase on master branch
v2: took last headers from net-next
include/linux/net_namespace.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 include/linux/net_namespace.h
include/linux/net_namespace.h new file +23 -0
@@ -0,0 +1,23 @@ +/* Copyright (c) 2015 6WIND S.A. +* Author: Nicolas Dichtel <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +*/ +#ifndef _LINUX_NET_NAMESPACE_H_ +#define _LINUX_NET_NAMESPACE_H_ + +/* Attributes of RTM_NEWNSID/RTM_GETNSID messages */ +enum { +NETNSA_NONE , +#define NETNSA_NSID_NOT_ASSIGNED -1 + NETNSA_NSID, +NETNSA_PID , +NETNSA_FD , + __NETNSA_MAX, +}; + +#define NETNSA_MAX (__NETNSA_MAX - 1) + +#endif /* _LINUX_NET_NAMESPACE_H_ */
Signature · 1 line
2.2.2
PATCH v3 2/4 ipnetns: allow to get and set netns ids
The kernel now provides ids for peer netns. This patch implements a new command 'set' to assign an id.
When netns are listed, if an id is assigned, it is now displayed.
Example:
$ ip netns add foo $ ip netns set foo 1 $ ip netns foo (id: 1) init_net
---
v3: rebase on master branch
v2: no change
include/libnetlink.h | 8 ++++ ip/ipnetns.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++- man/man8/ip-netns.8 | 14 +++++++ 3 files changed, 134 insertions(+), 1 deletion(-)
include/libnetlink.h +8 -0
@@ -158,6 +158,14 @@ extern int rtnl_from_file(FILE *, rtnl_filter_t handler,#define NDTA_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg))#endif +#ifndef NETNS_RTA +#define NETNS_RTA (r) \ + ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtgenmsg)))) +#endif +#ifndef NETNS_PAYLOAD +#define NETNS_PAYLOAD (n) NLMSG_PAYLOAD(n,sizeof(struct rtgenmsg)) +#endif +/* User defined nlmsg_type which is used mostly for logging netlink * messages from dump file */ #define NLMSG_TSTAMP 15
ip/ipnetns.c +112 -1
153 lines not on this page · raw message
man/man8/ip-netns.8 +14 -0
@@ -24,6 +24,10 @@ ip-netns \- process network namespace management .RI "[ " NETNSNAME " ]" .ti -8 +.BR "ip netns" " { " set " } " +.I NETNSNAME NETNSID + +.ti -8 .BR "ip netns identify" .RI "[ " PID " ]"
@@ -93,6 +97,16 @@ If option was specified then all the network namespace names will be removed. .TP +.B ip netns set NAME NETNSID - assign an id to a peer network namespace +.sp +This command assigns a id to a peer network namespace. This id is valid +only in the current network namespace. +This id will be used by the kernel in some netlink messages. If no id is +assigned when the kernel needs it, it will be automatically assigned by +the kernel. +Once it is assigned, it's not possible to change it. + +.TP .B ip netns identify [PID] - Report network namespaces names for process .sp This command walks through /var/run/netns and finds all the network
Signature · 1 line
2.2.2
PATCH v3 3/4 iplink: add support of IFLA_LINK_NETNSID attribute
In reply to Nicolas DichtelThis new attribute is now advertised by the kernel for x-netns interfaces. It's also possible to set it when an interface is created (and thus creating a x-netns interface with one single message).
Example:
$ ip netns add foo
$ ip netns add bar
$ ip -n foo netns set bar 15
$ ip -n foo link add ipip1 link-netnsid 15 type ipip remote 10.16.0.121 local 10.16.0.249
$ ip -n foo link ls ipip1
3: ipip1@NONE: <POINTOPOINT,NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default
link/ipip 10.16.0.249 peer 10.16.0.121 link-netnsid 15---
v3: rebase on master branch
v2: don't try to convert IFLA_LINK to the devname when IFLA_LINK_NETNSID is set
ip/ipaddress.c | 20 +++++++++++++++++--- ip/iplink.c | 10 ++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-)
ip/ipaddress.c +17 -3
@@ -28,6 +28,7 @@#include <linux/netdevice.h> #include <linux/if_arp.h> #include <linux/sockios.h> +#include <linux/net_namespace.h> #include "rt_names.h" #include "utils.h"
@@ -614,9 +615,13 @@ int print_linkinfo(const struct sockaddr_nl *who,if (iflink ==0 )fprintf (fp,"@NONE: " );else { -fprintf (fp,"@%s: " ,ll_idx_n2a (iflink, b1)); - m_flag =ll_index_to_flags (iflink); - m_flag = !(m_flag &IFF_UP ); +if (tb[IFLA_LINK_NETNSID ]) +fprintf (fp,"@if%d: " , iflink); +else { +fprintf (fp,"@%s: " ,ll_idx_n2a (iflink, b1)); + m_flag =ll_index_to_flags (iflink); + m_flag = !(m_flag &IFF_UP ); + } } }else {fprintf (fp,": " );
@@ -678,6 +683,15 @@ int print_linkinfo(const struct sockaddr_nl *who, } } +if (tb[IFLA_LINK_NETNSID ]) { +int id = *(int *)RTA_DATA (tb[IFLA_LINK_NETNSID ]); + +if (id >=0 ) +fprintf (fp," link-netnsid %d" , id); +else +fprintf (fp," link-netnsid unknown" ); + } +if (tb[IFLA_PROMISCUITY ] && show_details)fprintf (fp," promiscuity %u " , *(int *)RTA_DATA (tb[IFLA_PROMISCUITY ]));
ip/iplink.c +10 -0
@@ -72,6 +72,7 @@ void iplink_usage(void)fprintf (stderr," [ mtu MTU ]\n" );fprintf (stderr," [ netns PID ]\n" );fprintf (stderr," [ netns NAME ]\n" ); +fprintf (stderr," [ link-netnsid ID ]\n" );fprintf (stderr," [ alias NAME ]\n" );fprintf (stderr," [ vf NUM [ mac LLADDR ]\n" );fprintf (stderr," [ vlan VLANID [ qos VLAN-QOS ] ]\n" );
@@ -386,6 +387,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,int numtxqueues =-1 ;int numrxqueues =-1 ;int dev_index =0 ; +int link_netnsid =-1 ; *group =-1 ; ret = argc;
@@ -588,6 +590,14 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,addattr8 (&req->n,sizeof (*req),IFLA_INET6_ADDR_GEN_MODE , mode);addattr_nest_end (&req->n, afs6);addattr_nest_end (&req->n, afs); + }else if (matches (*argv,"link-netnsid" ) ==0 ) { +NEXT_ARG (); +if (link_netnsid !=-1 ) +duparg ("link-netnsid" , *argv); +if (get_integer (&link_netnsid, *argv,0 )) +invarg ("Invalid \"link-netnsid\" value\n" , *argv); +addattr32 (&req->n,sizeof (*req),IFLA_LINK_NETNSID , + link_netnsid); }else {if (strcmp (*argv,"dev" ) ==0 ) {NEXT_ARG ();
Signature · 1 line
2.2.2
PATCH v3 4/4 bridge/fdb: display link netns id
In reply to Nicolas DichtelWhen this attribute is set, it means that the i/o part of the related netdevice is in another netns.
---
v3: rebase on master branch
v2: new in the series
bridge/fdb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
bridge/fdb.c +5 -1
@@ -131,12 +131,16 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)if (ifindex) {char ifname[IF_NAMESIZE ]; -if (if_indextoname (ifindex, ifname)) +if (!tb[NDA_LINK_NETNSID ] && +if_indextoname (ifindex, ifname))fprintf (fp,"via %s " , ifname);else fprintf (fp,"via ifindex %u " , ifindex); } } +if (tb[NDA_LINK_NETNSID ]) +fprintf (fp,"link-netnsid %d " , +rta_getattr_u32 (tb[NDA_LINK_NETNSID ]));if (show_stats && tb[NDA_CACHEINFO ]) {struct nda_cacheinfo *ci =RTA_DATA (tb[NDA_CACHEINFO ]);
Signature · 1 line
2.2.2