diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-05-19 17:40:40 -0700 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-05-19 17:40:40 -0700 |
| commit | a80beece645358417219714d9362af64340eebef (patch) | |
| tree | 3e92bca081e548c96ead147c18efc6b26096d1f8 /lib/if.c | |
| parent | d6661008e2ded929a77e729ebbf20aa177d59f67 (diff) | |
'neighbor <if-name> interface' config support in BGP including RA/Zebra changes.
Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com>
Dinesh Dutt <ddutt@cumulusnetworks.com>
Diffstat (limited to 'lib/if.c')
| -rw-r--r-- | lib/if.c | 58 |
1 files changed, 58 insertions, 0 deletions
@@ -132,6 +132,9 @@ if_create (const char *name, int namelen) ifp->connected = list_new (); ifp->connected->del = (void (*) (void *)) connected_free; + ifp->nbr_connected = list_new (); + ifp->nbr_connected->del = (void (*) (void *)) nbr_connected_free; + /* Enable Link-detection by default */ SET_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION); @@ -150,6 +153,9 @@ if_delete_retain (struct interface *ifp) /* Free connected address list */ list_delete_all_node (ifp->connected); + + /* Free connected nbr address list */ + list_delete_all_node (ifp->nbr_connected); } /* Delete and free interface structure. */ @@ -161,6 +167,7 @@ if_delete (struct interface *ifp) if_delete_retain(ifp); list_free (ifp->connected); + list_free (ifp->nbr_connected); XFREE (MTYPE_IF, ifp); } @@ -652,6 +659,13 @@ connected_new (void) return XCALLOC (MTYPE_CONNECTED, sizeof (struct connected)); } +/* Allocate nbr connected structure. */ +struct nbr_connected * +nbr_connected_new (void) +{ + return XCALLOC (MTYPE_NBR_CONNECTED, sizeof (struct nbr_connected)); +} + /* Free connected structure. */ void connected_free (struct connected *connected) @@ -668,6 +682,30 @@ connected_free (struct connected *connected) XFREE (MTYPE_CONNECTED, connected); } +/* Free nbr connected structure. */ +void +nbr_connected_free (struct nbr_connected *connected) +{ + if (connected->address) + prefix_free (connected->address); + + XFREE (MTYPE_NBR_CONNECTED, connected); +} + +/* If same interface nbr address already exists... */ +struct nbr_connected * +nbr_connected_check (struct interface *ifp, struct prefix *p) +{ + struct nbr_connected *ifc; + struct listnode *node; + + for (ALL_LIST_ELEMENTS_RO (ifp->nbr_connected, node, ifc)) + if (prefix_same (ifc->address, p)) + return ifc; + + return NULL; +} + /* Print if_addr structure. */ static void __attribute__ ((unused)) connected_log (struct connected *connected, char *str) @@ -694,6 +732,26 @@ connected_log (struct connected *connected, char *str) zlog (NULL, LOG_INFO, "%s", logbuf); } +/* Print if_addr structure. */ +static void __attribute__ ((unused)) +nbr_connected_log (struct nbr_connected *connected, char *str) +{ + struct prefix *p; + struct interface *ifp; + char logbuf[BUFSIZ]; + char buf[BUFSIZ]; + + ifp = connected->ifp; + p = connected->address; + + snprintf (logbuf, BUFSIZ, "%s interface %s %s %s/%d ", + str, ifp->name, prefix_family_str (p), + inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), + p->prefixlen); + + zlog (NULL, LOG_INFO, "%s", logbuf); +} + /* If two connected address has same prefix return 1. */ static int connected_same_prefix (struct prefix *p1, struct prefix *p2) |
