Skip to content

Commit 1728d4f

Browse files
NicolasDichteldavem330
authored andcommitted
tunnels: advertise link netns via netlink
Implement rtnl_link_ops->get_link_net() callback so that IFLA_LINK_NETNSID is added to rtnetlink messages. Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d37512a commit 1728d4f

File tree

11 files changed

+34
-0
lines changed

11 files changed

+34
-0
lines changed

drivers/net/vxlan.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,6 +2923,13 @@ static int vxlan_fill_info(struct sk_buff *skb, const struct net_device *dev)
29232923
return -EMSGSIZE;
29242924
}
29252925

2926+
static struct net *vxlan_get_link_net(const struct net_device *dev)
2927+
{
2928+
struct vxlan_dev *vxlan = netdev_priv(dev);
2929+
2930+
return vxlan->net;
2931+
}
2932+
29262933
static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
29272934
.kind = "vxlan",
29282935
.maxtype = IFLA_VXLAN_MAX,
@@ -2934,6 +2941,7 @@ static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
29342941
.dellink = vxlan_dellink,
29352942
.get_size = vxlan_get_size,
29362943
.fill_info = vxlan_fill_info,
2944+
.get_link_net = vxlan_get_link_net,
29372945
};
29382946

29392947
static void vxlan_handle_lowerdev_unregister(struct vxlan_net *vn,

include/net/ip6_tunnel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ int ip6_tnl_xmit_ctl(struct ip6_tnl *t, const struct in6_addr *laddr,
7070
__u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw);
7171
__u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr,
7272
const struct in6_addr *raddr);
73+
struct net *ip6_tnl_get_link_net(const struct net_device *dev);
7374

7475
static inline void ip6tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
7576
{

include/net/ip_tunnels.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op,
141141
int ip_tunnel_init(struct net_device *dev);
142142
void ip_tunnel_uninit(struct net_device *dev);
143143
void ip_tunnel_dellink(struct net_device *dev, struct list_head *head);
144+
struct net *ip_tunnel_get_link_net(const struct net_device *dev);
144145
int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
145146
struct rtnl_link_ops *ops, char *devname);
146147

net/ipv4/ip_gre.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
829829
.dellink = ip_tunnel_dellink,
830830
.get_size = ipgre_get_size,
831831
.fill_info = ipgre_fill_info,
832+
.get_link_net = ip_tunnel_get_link_net,
832833
};
833834

834835
static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
@@ -843,6 +844,7 @@ static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
843844
.dellink = ip_tunnel_dellink,
844845
.get_size = ipgre_get_size,
845846
.fill_info = ipgre_fill_info,
847+
.get_link_net = ip_tunnel_get_link_net,
846848
};
847849

848850
static int __net_init ipgre_tap_init_net(struct net *net)

net/ipv4/ip_tunnel.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,14 @@ void ip_tunnel_dellink(struct net_device *dev, struct list_head *head)
972972
}
973973
EXPORT_SYMBOL_GPL(ip_tunnel_dellink);
974974

975+
struct net *ip_tunnel_get_link_net(const struct net_device *dev)
976+
{
977+
struct ip_tunnel *tunnel = netdev_priv(dev);
978+
979+
return tunnel->net;
980+
}
981+
EXPORT_SYMBOL(ip_tunnel_get_link_net);
982+
975983
int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
976984
struct rtnl_link_ops *ops, char *devname)
977985
{

net/ipv4/ip_vti.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ static struct rtnl_link_ops vti_link_ops __read_mostly = {
531531
.dellink = ip_tunnel_dellink,
532532
.get_size = vti_get_size,
533533
.fill_info = vti_fill_info,
534+
.get_link_net = ip_tunnel_get_link_net,
534535
};
535536

536537
static int __init vti_init(void)

net/ipv4/ipip.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ static struct rtnl_link_ops ipip_link_ops __read_mostly = {
498498
.dellink = ip_tunnel_dellink,
499499
.get_size = ipip_get_size,
500500
.fill_info = ipip_fill_info,
501+
.get_link_net = ip_tunnel_get_link_net,
501502
};
502503

503504
static struct xfrm_tunnel ipip_handler __read_mostly = {

net/ipv6/ip6_gre.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
16621662
.dellink = ip6gre_dellink,
16631663
.get_size = ip6gre_get_size,
16641664
.fill_info = ip6gre_fill_info,
1665+
.get_link_net = ip6_tnl_get_link_net,
16651666
};
16661667

16671668
static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {

net/ipv6/ip6_tunnel.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,14 @@ static int ip6_tnl_fill_info(struct sk_buff *skb, const struct net_device *dev)
17601760
return -EMSGSIZE;
17611761
}
17621762

1763+
struct net *ip6_tnl_get_link_net(const struct net_device *dev)
1764+
{
1765+
struct ip6_tnl *tunnel = netdev_priv(dev);
1766+
1767+
return tunnel->net;
1768+
}
1769+
EXPORT_SYMBOL(ip6_tnl_get_link_net);
1770+
17631771
static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
17641772
[IFLA_IPTUN_LINK] = { .type = NLA_U32 },
17651773
[IFLA_IPTUN_LOCAL] = { .len = sizeof(struct in6_addr) },
@@ -1783,6 +1791,7 @@ static struct rtnl_link_ops ip6_link_ops __read_mostly = {
17831791
.dellink = ip6_tnl_dellink,
17841792
.get_size = ip6_tnl_get_size,
17851793
.fill_info = ip6_tnl_fill_info,
1794+
.get_link_net = ip6_tnl_get_link_net,
17861795
};
17871796

17881797
static struct xfrm6_tunnel ip4ip6_handler __read_mostly = {

net/ipv6/ip6_vti.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,7 @@ static struct rtnl_link_ops vti6_link_ops __read_mostly = {
10161016
.changelink = vti6_changelink,
10171017
.get_size = vti6_get_size,
10181018
.fill_info = vti6_fill_info,
1019+
.get_link_net = ip6_tnl_get_link_net,
10191020
};
10201021

10211022
static void __net_exit vti6_destroy_tunnels(struct vti6_net *ip6n)

net/ipv6/sit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,7 @@ static struct rtnl_link_ops sit_link_ops __read_mostly = {
17631763
.get_size = ipip6_get_size,
17641764
.fill_info = ipip6_fill_info,
17651765
.dellink = ipip6_dellink,
1766+
.get_link_net = ip_tunnel_get_link_net,
17661767
};
17671768

17681769
static struct xfrm_tunnel sit_handler __read_mostly = {

0 commit comments

Comments
 (0)