mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 16:04:49 +00:00
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>
This commit is contained in:
parent
47e2eb270d
commit
42ed3bd77f
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include "zebra/rt_netlink.h"
|
#include "zebra/rt_netlink.h"
|
||||||
#include "zebra/kernel_netlink.h"
|
#include "zebra/kernel_netlink.h"
|
||||||
|
#include "lib/vxlan.h"
|
||||||
|
|
||||||
const char *nlmsg_type2str(uint16_t type)
|
const char *nlmsg_type2str(uint16_t type)
|
||||||
{
|
{
|
||||||
@ -92,6 +93,13 @@ const char *nlmsg_type2str(uint16_t type)
|
|||||||
case RTM_GETNEXTHOP:
|
case RTM_GETNEXTHOP:
|
||||||
return "GETNEXTHOP";
|
return "GETNEXTHOP";
|
||||||
|
|
||||||
|
case RTM_NEWTUNNEL:
|
||||||
|
return "NEWTUNNEL";
|
||||||
|
case RTM_DELTUNNEL:
|
||||||
|
return "DELTUNNEL";
|
||||||
|
case RTM_GETTUNNEL:
|
||||||
|
return "GETTUNNEL";
|
||||||
|
|
||||||
case RTM_NEWNETCONF:
|
case RTM_NEWNETCONF:
|
||||||
return "RTM_NEWNETCONF";
|
return "RTM_NEWNETCONF";
|
||||||
case RTM_DELNETCONF:
|
case RTM_DELNETCONF:
|
||||||
@ -1235,6 +1243,44 @@ next_rta:
|
|||||||
goto 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)
|
static const char *lwt_type2str(uint16_t type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -1523,6 +1569,7 @@ void nl_dump(void *msg, size_t msglen)
|
|||||||
struct nhmsg *nhm;
|
struct nhmsg *nhm;
|
||||||
struct netconfmsg *ncm;
|
struct netconfmsg *ncm;
|
||||||
struct ifinfomsg *ifi;
|
struct ifinfomsg *ifi;
|
||||||
|
struct tunnel_msg *tnlm;
|
||||||
struct fib_rule_hdr *frh;
|
struct fib_rule_hdr *frh;
|
||||||
char fbuf[128];
|
char fbuf[128];
|
||||||
char ibuf[128];
|
char ibuf[128];
|
||||||
@ -1639,6 +1686,18 @@ next_header:
|
|||||||
nlnh_dump(nhm, nlmsg->nlmsg_len - NLMSG_LENGTH(sizeof(*nhm)));
|
nlnh_dump(nhm, nlmsg->nlmsg_len - NLMSG_LENGTH(sizeof(*nhm)));
|
||||||
break;
|
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_NEWNETCONF:
|
||||||
case RTM_DELNETCONF:
|
case RTM_DELNETCONF:
|
||||||
ncm = NLMSG_DATA(nlmsg);
|
ncm = NLMSG_DATA(nlmsg);
|
||||||
|
Loading…
Reference in New Issue
Block a user