]> git.puffer.fish Git - mirror/frr.git/commitdiff
nhrpd: Introduce new - nflog mutlicast-nflog-group (1-65535) - command
authorAmol Lad <amol.lad@4rf.com>
Thu, 17 Dec 2020 08:08:06 +0000 (13:38 +0530)
committerReuben Dowle <reuben.dowle@4rf.com>
Mon, 5 Apr 2021 21:23:42 +0000 (09:23 +1200)
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
nhrpd/netlink.h
nhrpd/nhrp_multicast.c
nhrpd/nhrp_vty.c
nhrpd/nhrpd.h

index 74cb81daaa644a0bc5f82e8ea11f85ac4422fa97..5e971cabf13a46215d443b41ba0a789e30b44ba4 100644 (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);
index 42e3baaeeb85dcde466b20704b96d5925fc2623c..822a63b5f3276ad59a11e80a9df32c3b961d5d56 100644 (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);
 
index c16a816a36a527e84ffd01afa56e4c8384f1a794..48365bafb36422ecbb767a028bcee5210ba9ddf9 100644 (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);
index db7828f71583302ce5ae5095ce7b9dbca61221cb..5562916ae4100f995151cca7a18299d9bae1b814 100644 (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,