]> git.puffer.fish Git - matthieu/frr.git/commitdiff
nhrpd: cleaning netlink gre information
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 20 Dec 2019 10:23:05 +0000 (11:23 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 30 Apr 2021 08:33:18 +0000 (10:33 +0200)
flush netlink related dependencies with gre information.
Add some linux headers required to compile with it.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
include/linux/if_packet.h [new file with mode: 0644]
lib/zclient.c
nhrpd/linux.c
nhrpd/netlink.h
nhrpd/netlink_arp.c
nhrpd/netlink_gre.c [deleted file]
nhrpd/nhrp_interface.c
nhrpd/nhrp_main.c
nhrpd/subdir.am

diff --git a/include/linux/if_packet.h b/include/linux/if_packet.h
new file mode 100644 (file)
index 0000000..057edb3
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __LINUX_IF_PACKET_H
+#define __LINUX_IF_PACKET_H
+
+#include <linux/types.h>
+
+struct sockaddr_ll {
+       unsigned short sll_family;
+       __be16 sll_protocol;
+       int sll_ifindex;
+       unsigned short sll_hatype;
+       unsigned char sll_pkttype;
+       unsigned char sll_halen;
+       unsigned char sll_addr[8];
+};
+
+#endif
index e2f99aebf396b4cb2c1909a279e9c09bda78a7a2..3ea1789441b857d150578e657ee9c7cfd6ca0d1b 100644 (file)
@@ -4262,8 +4262,6 @@ int zclient_send_zebra_gre_request(struct zclient *client,
                                   struct interface *ifp)
 {
        struct stream *s;
-       ifindex_t idx_local;
-       int ret;
 
        if (!client || client->sock < 0) {
                zlog_err("%s : zclient not ready", __func__);
@@ -4278,7 +4276,4 @@ int zclient_send_zebra_gre_request(struct zclient *client,
        stream_putw_at(s, 0, stream_get_endp(s));
        zclient_send_message(client);
        return 0;
-stream_failure:
-       zlog_err("%s(): error reading response ..", __func__);
-       return 0;
 }
index f697311d4955e865235fab61bd768c9d91a860d7..b55e656562a736b29f8b92e06c85520adab868f7 100644 (file)
 #include <sys/types.h>
 #include <asm/types.h>
 #include <arpa/inet.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-#include <linux/ip.h>
+#include <linux/if_packet.h>
 #include <linux/if_arp.h>
-#include <linux/if_tunnel.h>
 #include <linux/limits.h>
 
 #include "nhrp_protocol.h"
 #include "os.h"
-#include "netlink.h"
 
 #ifndef HAVE_STRLCPY
 size_t strlcpy(char *__restrict dest,
index 5e971cabf13a46215d443b41ba0a789e30b44ba4..f1143a2b5ebbddbb71d74dcebf299f1241b0ea4e 100644 (file)
@@ -7,21 +7,16 @@
  * (at your option) any later version.
  */
 
-#include <stdint.h>
+#include <zebra.h>
+#include <vrf.h>
+#include <if.h>
 
-union sockunion;
-struct interface;
 
 extern int netlink_nflog_group;
 extern int netlink_mcast_nflog_group;
-extern int netlink_req_fd;
 
-void netlink_init(void);
 int netlink_configure_arp(unsigned int ifindex, int pf);
 void netlink_update_binding(struct interface *ifp, union sockunion *proto,
                            union sockunion *nbma);
 void netlink_set_nflog_group(int nlgroup);
 
-void netlink_gre_get_info(unsigned int ifindex, uint32_t *gre_key,
-                         unsigned int *link_index, struct in_addr *saddr);
-void netlink_gre_set_link(unsigned int ifindex, unsigned int link_index);
index ecea0a9ec57bedcda1a7f3c30bbd6de27fe6648b..5fcb31188896fa63dec343e748d67b813c0b53fb 100644 (file)
@@ -25,7 +25,6 @@
 #include "netlink.h"
 #include "znl.h"
 
-int netlink_req_fd = -1;
 int netlink_nflog_group;
 static int netlink_log_fd = -1;
 static struct thread *netlink_log_thread;
@@ -203,10 +202,3 @@ void nhrp_neighbor_operation(ZAPI_CALLBACK_ARGS)
                nhrp_cache_set_used(c, state == ZEBRA_NEIGH_STATE_REACHABLE);
        }
 }
-
-void netlink_init(void)
-{
-       netlink_req_fd = znl_open(NETLINK_ROUTE, 0);
-       if (netlink_req_fd < 0)
-               return;
-}
diff --git a/nhrpd/netlink_gre.c b/nhrpd/netlink_gre.c
deleted file mode 100644 (file)
index 3fdfa9c..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/* NHRP netlink/GRE tunnel configuration code
- * Copyright (c) 2014-2016 Timo Teräs
- *
- * This file is free software: you may copy, redistribute and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/socket.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-#include <linux/in.h>
-#include <linux/if.h>
-#include <linux/ip.h>
-#include <linux/ipv6.h>
-#include <linux/if_tunnel.h>
-
-#include "debug.h"
-#include "netlink.h"
-#include "znl.h"
-
-static int __netlink_gre_get_data(struct zbuf *zb, struct zbuf *data,
-                                 int ifindex)
-{
-       struct nlmsghdr *n;
-       struct ifinfomsg *ifi;
-       struct zbuf payload, rtapayload;
-       struct rtattr *rta;
-
-       debugf(NHRP_DEBUG_KERNEL, "netlink-link-gre: get-info %u", ifindex);
-
-       n = znl_nlmsg_push(zb, RTM_GETLINK, NLM_F_REQUEST);
-       ifi = znl_push(zb, sizeof(*ifi));
-       *ifi = (struct ifinfomsg){
-               .ifi_index = ifindex,
-       };
-       znl_nlmsg_complete(zb, n);
-
-       if (zbuf_send(zb, netlink_req_fd) < 0
-           || zbuf_recv(zb, netlink_req_fd) < 0)
-               return -1;
-
-       n = znl_nlmsg_pull(zb, &payload);
-       if (!n)
-               return -1;
-
-       if (n->nlmsg_type != RTM_NEWLINK)
-               return -1;
-
-       ifi = znl_pull(&payload, sizeof(struct ifinfomsg));
-       if (!ifi)
-               return -1;
-
-       debugf(NHRP_DEBUG_KERNEL,
-              "netlink-link-gre: ifindex %u, receive msg_type %u, msg_flags %u",
-              ifi->ifi_index, n->nlmsg_type, n->nlmsg_flags);
-
-       if (ifi->ifi_index != ifindex)
-               return -1;
-
-       while ((rta = znl_rta_pull(&payload, &rtapayload)) != NULL)
-               if (rta->rta_type == IFLA_LINKINFO)
-                       break;
-       if (!rta)
-               return -1;
-
-       payload = rtapayload;
-       while ((rta = znl_rta_pull(&payload, &rtapayload)) != NULL)
-               if (rta->rta_type == IFLA_INFO_DATA)
-                       break;
-       if (!rta)
-               return -1;
-
-       *data = rtapayload;
-       return 0;
-}
-
-void netlink_gre_get_info(unsigned int ifindex, uint32_t *gre_key,
-                         unsigned int *link_index, struct in_addr *saddr)
-{
-       struct zbuf *zb = zbuf_alloc(8192), data, rtapl;
-       struct rtattr *rta;
-
-       *link_index = 0;
-       *gre_key = 0;
-       saddr->s_addr = 0;
-
-       if (__netlink_gre_get_data(zb, &data, ifindex) < 0)
-               goto err;
-
-       while ((rta = znl_rta_pull(&data, &rtapl)) != NULL) {
-               switch (rta->rta_type) {
-               case IFLA_GRE_LINK:
-                       *link_index = zbuf_get32(&rtapl);
-                       break;
-               case IFLA_GRE_IKEY:
-               case IFLA_GRE_OKEY:
-                       *gre_key = zbuf_get32(&rtapl);
-                       break;
-               case IFLA_GRE_LOCAL:
-                       saddr->s_addr = zbuf_get32(&rtapl);
-                       break;
-               }
-       }
-err:
-       zbuf_free(zb);
-}
-
-void netlink_gre_set_link(unsigned int ifindex, unsigned int link_index)
-{
-       struct nlmsghdr *n;
-       struct ifinfomsg *ifi;
-       struct rtattr *rta_info, *rta_data, *rta;
-       struct zbuf *zr = zbuf_alloc(8192), data, rtapl;
-       struct zbuf *zb = zbuf_alloc(8192);
-       size_t len;
-
-       if (__netlink_gre_get_data(zr, &data, ifindex) < 0)
-               goto err;
-
-       n = znl_nlmsg_push(zb, RTM_NEWLINK, NLM_F_REQUEST);
-       ifi = znl_push(zb, sizeof(*ifi));
-       *ifi = (struct ifinfomsg){
-               .ifi_index = ifindex,
-       };
-       rta_info = znl_rta_nested_push(zb, IFLA_LINKINFO);
-       znl_rta_push(zb, IFLA_INFO_KIND, "gre", 3);
-       rta_data = znl_rta_nested_push(zb, IFLA_INFO_DATA);
-
-       znl_rta_push_u32(zb, IFLA_GRE_LINK, link_index);
-       while ((rta = znl_rta_pull(&data, &rtapl)) != NULL) {
-               if (rta->rta_type == IFLA_GRE_LINK)
-                       continue;
-               len = zbuf_used(&rtapl);
-               znl_rta_push(zb, rta->rta_type, zbuf_pulln(&rtapl, len), len);
-       }
-
-       znl_rta_nested_complete(zb, rta_data);
-       znl_rta_nested_complete(zb, rta_info);
-
-       znl_nlmsg_complete(zb, n);
-       zbuf_send(zb, netlink_req_fd);
-       zbuf_recv(zb, netlink_req_fd);
-err:
-       zbuf_free(zb);
-       zbuf_free(zr);
-}
index 12c86c3876d7e11d3aa4ceca20a010a726eb7ce1..541e5a992a491497b4bba5b6870c6e8a72fb0251 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "nhrpd.h"
 #include "os.h"
-#include "netlink.h"
 #include "hash.h"
 
 DEFINE_MTYPE_STATIC(NHRPD, NHRP_IF, "NHRP interface");
index e9bce3e09a3b0253df2f0c5484f5475a7c616dc2..c2111a7706ff2cf61804bf33144c9b821d843ad9 100644 (file)
@@ -26,7 +26,6 @@
 #include "filter.h"
 
 #include "nhrpd.h"
-#include "netlink.h"
 #include "nhrp_errors.h"
 
 DEFINE_MGROUP(NHRPD, "NHRP");
@@ -154,7 +153,6 @@ int main(int argc, char **argv)
        assert(nhrpd_privs.change);
        nhrpd_privs.change(ZPRIVS_RAISE);
 
-       netlink_init();
        evmgr_init();
        nhrp_vc_init();
        nhrp_packet_init();
index d00aecc1ead75d4600d8b393f9f92bb2b6bea5f6..9a186d6ed840b9c4f98bc5ac97a12d86faf1edfc 100644 (file)
@@ -13,7 +13,6 @@ nhrpd_nhrpd_LDADD = lib/libfrr.la lib/libfrrcares.la $(LIBCAP)
 nhrpd_nhrpd_SOURCES = \
        nhrpd/linux.c \
        nhrpd/netlink_arp.c \
-       nhrpd/netlink_gre.c \
        nhrpd/nhrp_cache.c \
        nhrpd/nhrp_errors.c \
        nhrpd/nhrp_event.c \