Skip to content

Commit 7b8135f

Browse files
Roopa Prabhudavem330
Roopa Prabhu
authored andcommitted
rtnetlink: add new rtm tunnel api for tunnel id filtering
This patch adds new rtm tunnel msg and api for tunnel id filtering in dst_metadata devices. First dst_metadata device to use the api is vxlan driver with AF_BRIDGE family. This and later changes add ability in vxlan driver to do tunnel id filtering (or vni filtering) on dst_metadata devices. This is similar to vlan api in the vlan filtering bridge. this patch includes selinux nlmsg_route_perms support for RTM_*TUNNEL api from Benjamin Poirier. Signed-off-by: Roopa Prabhu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent efe0f94 commit 7b8135f

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

include/uapi/linux/if_link.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,32 @@ enum ipvlan_mode {
713713
#define IPVLAN_F_PRIVATE 0x01
714714
#define IPVLAN_F_VEPA 0x02
715715

716+
/* Tunnel RTM header */
717+
struct tunnel_msg {
718+
__u8 family;
719+
__u8 reserved1;
720+
__u16 reserved2;
721+
__u32 ifindex;
722+
};
723+
716724
/* VXLAN section */
725+
enum {
726+
VXLAN_VNIFILTER_ENTRY_UNSPEC,
727+
VXLAN_VNIFILTER_ENTRY_START,
728+
VXLAN_VNIFILTER_ENTRY_END,
729+
VXLAN_VNIFILTER_ENTRY_GROUP,
730+
VXLAN_VNIFILTER_ENTRY_GROUP6,
731+
__VXLAN_VNIFILTER_ENTRY_MAX
732+
};
733+
#define VXLAN_VNIFILTER_ENTRY_MAX (__VXLAN_VNIFILTER_ENTRY_MAX - 1)
734+
735+
enum {
736+
VXLAN_VNIFILTER_UNSPEC,
737+
VXLAN_VNIFILTER_ENTRY,
738+
__VXLAN_VNIFILTER_MAX
739+
};
740+
#define VXLAN_VNIFILTER_MAX (__VXLAN_VNIFILTER_MAX - 1)
741+
717742
enum {
718743
IFLA_VXLAN_UNSPEC,
719744
IFLA_VXLAN_ID,
@@ -745,6 +770,7 @@ enum {
745770
IFLA_VXLAN_GPE,
746771
IFLA_VXLAN_TTL_INHERIT,
747772
IFLA_VXLAN_DF,
773+
IFLA_VXLAN_VNIFILTER, /* only applicable with COLLECT_METADATA mode */
748774
__IFLA_VXLAN_MAX
749775
};
750776
#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)

include/uapi/linux/rtnetlink.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ enum {
185185
RTM_GETNEXTHOPBUCKET,
186186
#define RTM_GETNEXTHOPBUCKET RTM_GETNEXTHOPBUCKET
187187

188+
RTM_NEWTUNNEL = 120,
189+
#define RTM_NEWTUNNEL RTM_NEWTUNNEL
190+
RTM_DELTUNNEL,
191+
#define RTM_DELTUNNEL RTM_DELTUNNEL
192+
RTM_GETTUNNEL,
193+
#define RTM_GETTUNNEL RTM_GETTUNNEL
194+
188195
__RTM_MAX,
189196
#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
190197
};
@@ -756,6 +763,8 @@ enum rtnetlink_groups {
756763
#define RTNLGRP_BRVLAN RTNLGRP_BRVLAN
757764
RTNLGRP_MCTP_IFADDR,
758765
#define RTNLGRP_MCTP_IFADDR RTNLGRP_MCTP_IFADDR
766+
RTNLGRP_TUNNEL,
767+
#define RTNLGRP_TUNNEL RTNLGRP_TUNNEL
759768
__RTNLGRP_MAX
760769
};
761770
#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)

security/selinux/nlmsgtab.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ static const struct nlmsg_perm nlmsg_route_perms[] =
9191
{ RTM_NEWNEXTHOPBUCKET, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
9292
{ RTM_DELNEXTHOPBUCKET, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
9393
{ RTM_GETNEXTHOPBUCKET, NETLINK_ROUTE_SOCKET__NLMSG_READ },
94+
{ RTM_NEWTUNNEL, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
95+
{ RTM_DELTUNNEL, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
96+
{ RTM_GETTUNNEL, NETLINK_ROUTE_SOCKET__NLMSG_READ },
9497
};
9598

9699
static const struct nlmsg_perm nlmsg_tcpdiag_perms[] =
@@ -176,7 +179,7 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)
176179
* structures at the top of this file with the new mappings
177180
* before updating the BUILD_BUG_ON() macro!
178181
*/
179-
BUILD_BUG_ON(RTM_MAX != (RTM_NEWNEXTHOPBUCKET + 3));
182+
BUILD_BUG_ON(RTM_MAX != (RTM_NEWTUNNEL + 3));
180183
err = nlmsg_perm(nlmsg_type, perm, nlmsg_route_perms,
181184
sizeof(nlmsg_route_perms));
182185
break;

0 commit comments

Comments
 (0)