nhrpd: Introduce new - nflog mutlicast-nflog-group (1-65535) - command

Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
This commit is contained in:
Amol Lad 2020-12-17 13:38:06 +05:30 committed by Reuben Dowle
parent 9f7f6d3c6b
commit 9084e20961
4 changed files with 42 additions and 14 deletions

View File

@ -13,6 +13,7 @@ union sockunion;
struct interface;
extern int netlink_nflog_group;
extern int netlink_mcast_nflog_group;
extern int netlink_req_fd;
void netlink_init(void);

View File

@ -30,7 +30,7 @@
DEFINE_MTYPE_STATIC(NHRPD, NHRP_MULTICAST, "NHRP Multicast")
static int netlink_mcast_nflog_group;
int netlink_mcast_nflog_group;
static int netlink_mcast_log_fd = -1;
static struct thread *netlink_mcast_log_thread;
@ -201,15 +201,7 @@ static void netlink_mcast_log_register(int fd, int group)
zbuf_free(zb);
}
static int nhrp_multicast_free(struct interface *ifp,
struct nhrp_multicast *mcast)
{
list_del(&mcast->list_entry);
XFREE(MTYPE_NHRP_MULTICAST, mcast);
return 0;
}
static void netlink_mcast_set_nflog_group(struct interface *ifp, int nlgroup)
void netlink_mcast_set_nflog_group(int nlgroup)
{
if (netlink_mcast_log_fd >= 0) {
THREAD_OFF(netlink_mcast_log_thread);
@ -232,6 +224,14 @@ static void netlink_mcast_set_nflog_group(struct interface *ifp, int nlgroup)
}
}
static int nhrp_multicast_free(struct interface *ifp,
struct nhrp_multicast *mcast)
{
list_del(&mcast->list_entry);
XFREE(MTYPE_NHRP_MULTICAST, mcast);
return 0;
}
int nhrp_multicast_add(struct interface *ifp, afi_t afi,
union sockunion *nbma_addr)
{
@ -252,9 +252,6 @@ int nhrp_multicast_add(struct interface *ifp, afi_t afi,
};
list_add_tail(&mcast->list_entry, &nifp->afi[afi].mcastlist_head);
if (netlink_mcast_log_fd == -1)
netlink_mcast_set_nflog_group(ifp, MCAST_NFLOG_GROUP);
sockunion2str(nbma_addr, buf, sizeof(buf));
debugf(NHRP_DEBUG_COMMON, "Adding multicast entry (%s)", buf);

View File

@ -187,6 +187,9 @@ static int nhrp_config_write(struct vty *vty)
if (netlink_nflog_group) {
vty_out(vty, "nhrp nflog-group %d\n", netlink_nflog_group);
}
if (netlink_mcast_nflog_group)
vty_out(vty, "nhrp multicast-nflog-group %d\n",
netlink_mcast_nflog_group);
return 0;
}
@ -257,6 +260,31 @@ DEFUN(no_nhrp_nflog_group, no_nhrp_nflog_group_cmd,
return CMD_SUCCESS;
}
DEFUN(nhrp_multicast_nflog_group, nhrp_multicast_nflog_group_cmd,
"nhrp multicast-nflog-group (1-65535)",
NHRP_STR
"Specify NFLOG group number for Multicast Packets\n"
"NFLOG group number\n")
{
uint32_t nfgroup;
nfgroup = strtoul(argv[2]->arg, NULL, 10);
netlink_mcast_set_nflog_group(nfgroup);
return CMD_SUCCESS;
}
DEFUN(no_nhrp_multicast_nflog_group, no_nhrp_multicast_nflog_group_cmd,
"no nhrp multicast-nflog-group [(1-65535)]",
NO_STR
NHRP_STR
"Specify NFLOG group number\n"
"NFLOG group number\n")
{
netlink_mcast_set_nflog_group(0);
return CMD_SUCCESS;
}
DEFUN(tunnel_protection, tunnel_protection_cmd,
"tunnel protection vici profile PROFILE [fallback-profile FALLBACK]",
"NHRP/GRE integration\n"
@ -1234,6 +1262,8 @@ void nhrp_config_init(void)
install_element(CONFIG_NODE, &no_nhrp_event_socket_cmd);
install_element(CONFIG_NODE, &nhrp_nflog_group_cmd);
install_element(CONFIG_NODE, &no_nhrp_nflog_group_cmd);
install_element(CONFIG_NODE, &nhrp_multicast_nflog_group_cmd);
install_element(CONFIG_NODE, &no_nhrp_multicast_nflog_group_cmd);
/* interface specific commands */
install_node(&nhrp_interface_node);

View File

@ -24,7 +24,6 @@ DECLARE_MGROUP(NHRPD);
#define NHRP_VTY_PORT 2610
#define NHRP_DEFAULT_CONFIG "nhrpd.conf"
#define MCAST_NFLOG_GROUP 224
extern struct thread_master *master;
@ -367,6 +366,7 @@ void nhrp_multicast_interface_del(struct interface *ifp);
void nhrp_multicast_foreach(struct interface *ifp, afi_t afi,
void (*cb)(struct nhrp_multicast *, void *),
void *ctx);
void netlink_mcast_set_nflog_group(int nlgroup);
void nhrp_route_update_nhrp(const struct prefix *p, struct interface *ifp);
void nhrp_route_announce(int add, enum nhrp_cache_type type,