summaryrefslogtreecommitdiffstats
path: root/zebra
diff options
context:
space:
mode:
authorChirag Shah <chirag@nvidia.com>2022-05-17 07:52:54 +0200
committerChirag Shah <chirag@nvidia.com>2022-05-18 16:56:44 +0200
commit42ed3bd77f418cc8c14465c15b57770a59aeaa37 (patch)
tree77004647a7aa672327a66e4a74d874fdd016f48b /zebra
parentzebra: netlink registry rtm tunnel notif (diff)
downloadfrr-42ed3bd77f418cc8c14465c15b57770a59aeaa37.tar.xz
frr-42ed3bd77f418cc8c14465c15b57770a59aeaa37.zip
zebra: add netlink tunnel msg to dump routine
This patch parses vxlan vnifilter rtm tunnel message which contains vni mapping to vxlan device. The new notifications are RTM_NEWTUNNEL, RTM_DELTUNNEL, and RTM_GETTUNNEL. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/ linux.git/commit/?h=v5.18-rc7&id=7b8135f4df98b155b23754b6065c157861e268f1 Testing Done: 2022/05/18 00:34:25 ZEBRA: netlink_recv_msg: << netlink message dump [recv] 2022/05/18 00:34:25 ZEBRA: nlmsghdr [len=36 type=(120) NEWTUNNEL flags=(0x0000) {} seq=0 pid=0] 2022/05/18 00:34:25 ZEBRA: tnlm [family=(7) AF_BRIDGE ifindex=46 2022/05/18 00:34:25 ZEBRA: vni_start 4001, vni_end 0 Signed-off-by: Chirag Shah <chirag@nvidia.com>
Diffstat (limited to 'zebra')
-rw-r--r--zebra/debug_nl.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/zebra/debug_nl.c b/zebra/debug_nl.c
index 98b3a9ed5..cabb86c96 100644
--- a/zebra/debug_nl.c
+++ b/zebra/debug_nl.c
@@ -33,6 +33,7 @@
#include "zebra/rt_netlink.h"
#include "zebra/kernel_netlink.h"
+#include "lib/vxlan.h"
const char *nlmsg_type2str(uint16_t type)
{
@@ -92,6 +93,13 @@ const char *nlmsg_type2str(uint16_t type)
case RTM_GETNEXTHOP:
return "GETNEXTHOP";
+ case RTM_NEWTUNNEL:
+ return "NEWTUNNEL";
+ case RTM_DELTUNNEL:
+ return "DELTUNNEL";
+ case RTM_GETTUNNEL:
+ return "GETTUNNEL";
+
case RTM_NEWNETCONF:
return "RTM_NEWNETCONF";
case RTM_DELNETCONF:
@@ -1235,6 +1243,44 @@ next_rta:
goto next_rta;
}
+static void nltnl_dump(struct tunnel_msg *tnlm, size_t msglen)
+{
+ struct rtattr *attr;
+ vni_t vni_start = 0, vni_end = 0;
+ struct rtattr *ttb[VXLAN_VNIFILTER_ENTRY_MAX + 1];
+ uint8_t rta_type;
+
+ attr = TUNNEL_RTA(tnlm);
+next_attr:
+ /* Check the header for valid length and for outbound access. */
+ if (RTA_OK(attr, msglen) == 0)
+ return;
+
+ rta_type = attr->rta_type & NLA_TYPE_MASK;
+
+ if (rta_type != VXLAN_VNIFILTER_ENTRY) {
+ attr = RTA_NEXT(attr, msglen);
+ goto next_attr;
+ }
+
+ memset(ttb, 0, sizeof(ttb));
+
+ netlink_parse_rtattr_flags(ttb, VXLAN_VNIFILTER_ENTRY_MAX,
+ RTA_DATA(attr), RTA_PAYLOAD(attr),
+ NLA_F_NESTED);
+
+ if (ttb[VXLAN_VNIFILTER_ENTRY_START])
+ vni_start =
+ *(uint32_t *)RTA_DATA(ttb[VXLAN_VNIFILTER_ENTRY_START]);
+
+ if (ttb[VXLAN_VNIFILTER_ENTRY_END])
+ vni_end = *(uint32_t *)RTA_DATA(ttb[VXLAN_VNIFILTER_ENTRY_END]);
+ zlog_debug(" vni_start %u, vni_end %u", vni_start, vni_end);
+
+ attr = RTA_NEXT(attr, msglen);
+ goto next_attr;
+}
+
static const char *lwt_type2str(uint16_t type)
{
switch (type) {
@@ -1523,6 +1569,7 @@ void nl_dump(void *msg, size_t msglen)
struct nhmsg *nhm;
struct netconfmsg *ncm;
struct ifinfomsg *ifi;
+ struct tunnel_msg *tnlm;
struct fib_rule_hdr *frh;
char fbuf[128];
char ibuf[128];
@@ -1639,6 +1686,18 @@ next_header:
nlnh_dump(nhm, nlmsg->nlmsg_len - NLMSG_LENGTH(sizeof(*nhm)));
break;
+ case RTM_NEWTUNNEL:
+ case RTM_DELTUNNEL:
+ case RTM_GETTUNNEL:
+ tnlm = NLMSG_DATA(nlmsg);
+ zlog_debug(" tnlm [family=(%d) %s ifindex=%d ", tnlm->family,
+ af_type2str(tnlm->family), tnlm->ifindex);
+ nltnl_dump(tnlm,
+ nlmsg->nlmsg_len -
+ NLMSG_LENGTH(sizeof(struct tunnel_msg)));
+ break;
+
+
case RTM_NEWNETCONF:
case RTM_DELNETCONF:
ncm = NLMSG_DATA(nlmsg);