]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #3543 from donaldsharp/eigrp_router_id_is_the_bee
authorRenato Westphal <renato@openbsd.org>
Wed, 2 Jan 2019 00:39:03 +0000 (22:39 -0200)
committerGitHub <noreply@github.com>
Wed, 2 Jan 2019 00:39:03 +0000 (22:39 -0200)
Eigrp router id cleanup

1  2 
eigrpd/eigrp_structs.h
eigrpd/eigrp_vty.c
eigrpd/eigrpd.c

diff --combined eigrpd/eigrp_structs.h
index a9c5db53618c41c7fa4197bdf1f7471b6dd0c8f4,f661d9ec581bec5d57c34174dd7c7ec6bbda6833..644ab0829f8b32bc85f66bc590f720d841c2f383
@@@ -79,8 -79,8 +79,8 @@@ struct eigrp 
        char *name;
  
        /* EIGRP Router ID. */
-       uint32_t router_id;     /* Configured automatically. */
-       uint32_t router_id_static; /* Configured manually. */
+       struct in_addr router_id;       /* Configured automatically. */
+       struct in_addr router_id_static; /* Configured manually. */
  
        struct list *eiflist;             /* eigrp interfaces */
        uint8_t passive_interface_default; /* passive-interface default */
                uint32_t metric;
        } route_map[ZEBRA_ROUTE_MAX];
  
 +      /* distribute_ctx */
 +      struct distribute_ctx *distribute_ctx;
 +
        QOBJ_FIELDS
  };
  DECLARE_QOBJ_TYPE(eigrp)
diff --combined eigrpd/eigrp_vty.c
index b9486e026004797c98bfb93f1875adffa6792119,f29305e7a3117015726358fe6ef39c946e60b2dd..474f683989c07fbd5e75792136295f44f7c2f0e5
@@@ -174,7 -174,7 +174,7 @@@ static int config_write_eigrp_distribut
        int write = 0;
  
        /* Distribute configuration. */
 -      write += config_write_distribute(vty);
 +      write += config_write_distribute(vty, eigrp->distribute_ctx);
  
        return write;
  }
@@@ -191,15 -191,10 +191,10 @@@ static int config_write_eigrp_router(st
  
        write++;
  
-       if (!eigrp->networks)
-               return write;
        /* Router ID print. */
-       if (eigrp->router_id_static != 0) {
-               struct in_addr router_id_static;
-               router_id_static.s_addr = htonl(eigrp->router_id_static);
+       if (eigrp->router_id_static.s_addr != 0) {
                vty_out(vty, " eigrp router-id %s\n",
-                       inet_ntoa(router_id_static));
+                       inet_ntoa(eigrp->router_id_static));
        }
  
        /* Network area print. */
@@@ -255,29 -250,31 +250,31 @@@ DEFUN (no_router_eigrp
        return CMD_SUCCESS;
  }
  
- DEFUN (eigrp_router_id,
+ DEFPY (eigrp_router_id,
         eigrp_router_id_cmd,
-        "eigrp router-id A.B.C.D",
+        "eigrp router-id A.B.C.D$addr",
         "EIGRP specific commands\n"
         "Router ID for this EIGRP process\n"
         "EIGRP Router-ID in IP address format\n")
  {
-       // struct eigrp *eigrp = vty->index;
-       /*TODO: */
+       VTY_DECLVAR_CONTEXT(eigrp, eigrp);
+       eigrp->router_id_static = addr;
  
        return CMD_SUCCESS;
  }
  
- DEFUN (no_eigrp_router_id,
+ DEFPY (no_eigrp_router_id,
         no_eigrp_router_id_cmd,
-        "no eigrp router-id A.B.C.D",
+        "no eigrp router-id [A.B.C.D$addr]",
         NO_STR
         "EIGRP specific commands\n"
         "Router ID for this EIGRP process\n"
         "EIGRP Router-ID in IP address format\n")
  {
-       // struct eigrp *eigrp = vty->index;
-       /*TODO: */
+       VTY_DECLVAR_CONTEXT(eigrp, eigrp);
+       eigrp->router_id_static.s_addr = 0;
  
        return CMD_SUCCESS;
  }
diff --combined eigrpd/eigrpd.c
index 38d54edfca124f31348e5cf6fdd74dd743843810,2b2293f24f4c8c84f7dbf0c38445cf1fd86c0827..5541ec15f343f695971ee2f63624d5244533b555
@@@ -44,7 -44,6 +44,7 @@@
  #include "keychain.h"
  #include "libfrr.h"
  #include "lib_errors.h"
 +#include "distribute.h"
  
  #include "eigrpd/eigrp_structs.h"
  #include "eigrpd/eigrpd.h"
@@@ -56,7 -55,6 +56,7 @@@
  #include "eigrpd/eigrp_network.h"
  #include "eigrpd/eigrp_topology.h"
  #include "eigrpd/eigrp_memory.h"
 +#include "eigrpd/eigrp_filter.h"
  
  DEFINE_QOBJ_TYPE(eigrp)
  
@@@ -97,21 -95,21 +97,21 @@@ void eigrp_router_id_update(struct eigr
  {
        struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
        struct interface *ifp;
-       uint32_t router_id, router_id_old;
+       struct in_addr router_id, router_id_old;
  
        router_id_old = eigrp->router_id;
  
-       if (eigrp->router_id_static != 0)
+       if (eigrp->router_id_static.s_addr != 0)
                router_id = eigrp->router_id_static;
  
-       else if (eigrp->router_id != 0)
+       else if (eigrp->router_id.s_addr != 0)
                router_id = eigrp->router_id;
  
        else
-               router_id = router_id_zebra.s_addr;
+               router_id = router_id_zebra;
  
        eigrp->router_id = router_id;
-       if (router_id_old != router_id) {
+       if (router_id_old.s_addr != router_id.s_addr) {
                //      if (IS_DEBUG_EIGRP_EVENT)
                //        zlog_debug("Router-ID[NEW:%s]: Update",
                //        inet_ntoa(eigrp->router_id));
@@@ -144,8 -142,8 +144,8 @@@ static struct eigrp *eigrp_new(const ch
        /* init information relevant to peers */
        eigrp->vrid = 0;
        eigrp->AS = atoi(AS);
-       eigrp->router_id = 0L;
-       eigrp->router_id_static = 0L;
+       eigrp->router_id.s_addr = 0;
+       eigrp->router_id_static.s_addr = 0;
        eigrp->sequence_number = 1;
  
        /*Configure default K Values for EIGRP Process*/
        eigrp->routemap[EIGRP_FILTER_IN] = NULL;
        eigrp->routemap[EIGRP_FILTER_OUT] = NULL;
  
 +      /* Distribute list install. */
 +      eigrp->distribute_ctx = distribute_list_ctx_create(
 +                                         vrf_lookup_by_id(VRF_DEFAULT));
 +      distribute_list_add_hook(eigrp->distribute_ctx,
 +                               eigrp_distribute_update);
 +      distribute_list_delete_hook(eigrp->distribute_ctx,
 +                                  eigrp_distribute_update);
        QOBJ_REG(eigrp, eigrp);
        return eigrp;
  }
@@@ -288,7 -279,6 +288,7 @@@ void eigrp_finish_final(struct eigrp *e
        listnode_delete(eigrp_om->eigrp, eigrp);
  
        stream_free(eigrp->ibuf);
 +      distribute_list_delete(&eigrp->distribute_ctx);
        XFREE(MTYPE_EIGRP_TOP, eigrp);
  }