X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=babeld%2Fbabeld.c;h=0517cbea6d5a9e9f2a1c864a3d071823981f96e9;hb=c52e2ecf95a9be318912caacc0851d9307e679f7;hp=207c37d9b1f44bf4319d623954b0218fcb295abd;hpb=09fdc88c8cb0cd4169ae97b652d82f6a174a4041;p=mirror_frr.git diff --git a/babeld/babeld.c b/babeld/babeld.c index 207c37d9b..0517cbea6 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -29,6 +29,7 @@ THE SOFTWARE. #include "prefix.h" #include "filter.h" #include "plist.h" +#include "lib_errors.h" #include "babel_main.h" #include "babeld.h" @@ -43,6 +44,7 @@ THE SOFTWARE. #include "babel_filter.h" #include "babel_zebra.h" #include "babel_memory.h" +#include "babel_errors.h" static int babel_init_routing_process(struct thread *thread); static void babel_get_myid(void); @@ -143,7 +145,8 @@ babel_create_routing_process (void) /* Make socket for Babel protocol. */ protocol_socket = babel_socket(protocol_port); if (protocol_socket < 0) { - zlog_err("Couldn't create link local socket: %s", safe_strerror(errno)); + flog_err_sys(EC_LIB_SOCKET, "Couldn't create link local socket: %s", + safe_strerror(errno)); goto fail; } @@ -164,9 +167,9 @@ static int babel_read_protocol (struct thread *thread) { int rc; + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct interface *ifp = NULL; struct sockaddr_in6 sin6; - struct listnode *linklist_node = NULL; assert(babel_routing_process != NULL); assert(protocol_socket >= 0); @@ -176,10 +179,10 @@ babel_read_protocol (struct thread *thread) (struct sockaddr*)&sin6, sizeof(sin6)); if(rc < 0) { if(errno != EAGAIN && errno != EINTR) { - zlog_err("recv: %s", safe_strerror(errno)); + flog_err_sys(EC_LIB_SOCKET, "recv: %s", safe_strerror(errno)); } } else { - FOR_ALL_INTERFACES(ifp, linklist_node) { + FOR_ALL_INTERFACES(vrf, ifp) { if(!if_up(ifp)) continue; if(ifp->ifindex == (ifindex_t)sin6.sin6_scope_id) { @@ -214,8 +217,8 @@ babel_init_routing_process(struct thread *thread) static void babel_get_myid(void) { + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct interface *ifp = NULL; - struct listnode *linklist_node = NULL; int rc; int i; @@ -224,12 +227,12 @@ babel_get_myid(void) return; } - FOR_ALL_INTERFACES(ifp, linklist_node) { + FOR_ALL_INTERFACES(vrf, ifp) { /* ifp->ifindex is not necessarily valid at this point */ int ifindex = if_nametoindex(ifp->name); if(ifindex > 0) { unsigned char eui[8]; - rc = if_eui64(ifp->name, ifindex, eui); + rc = if_eui64(ifindex, eui); if(rc < 0) continue; memcpy(myid, eui, 8); @@ -245,18 +248,20 @@ babel_get_myid(void) ifname = if_indextoname(i, buf); if(ifname == NULL) continue; - rc = if_eui64(ifname, i, eui); + rc = if_eui64(i, eui); if(rc < 0) continue; memcpy(myid, eui, 8); return; } - zlog_err("Warning: couldn't find router id -- using random value."); + flog_err(EC_BABEL_CONFIG, + "Warning: couldn't find router id -- using random value."); rc = read_random_bytes(myid, 8); if(rc < 0) { - zlog_err("read(random): %s (cannot assign an ID)",safe_strerror(errno)); + flog_err(EC_BABEL_CONFIG, "read(random): %s (cannot assign an ID)", + safe_strerror(errno)); exit(1); } /* Clear group and global bits */ @@ -268,10 +273,10 @@ babel_get_myid(void) static void babel_initial_noise(void) { + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct interface *ifp = NULL; - struct listnode *linklist_node = NULL; - FOR_ALL_INTERFACES(ifp, linklist_node) { + FOR_ALL_INTERFACES(vrf, ifp) { if(!if_up(ifp)) continue; /* Apply jitter before we send the first message. */ @@ -281,7 +286,7 @@ babel_initial_noise(void) send_wildcard_retraction(ifp); } - FOR_ALL_INTERFACES(ifp, linklist_node) { + FOR_ALL_INTERFACES(vrf, ifp) { if(!if_up(ifp)) continue; usleep(roughly(10000)); @@ -319,8 +324,8 @@ static int babel_main_loop(struct thread *thread) { struct timeval tv; + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct interface *ifp = NULL; - struct listnode *linklist_node = NULL; while(1) { gettime(&babel_now); @@ -361,7 +366,7 @@ babel_main_loop(struct thread *thread) source_expiry_time = babel_now.tv_sec + roughly(300); } - FOR_ALL_INTERFACES(ifp, linklist_node) { + FOR_ALL_INTERFACES(vrf, ifp) { babel_interface_nfo *babel_ifp = NULL; if(!if_up(ifp)) continue; @@ -385,7 +390,7 @@ babel_main_loop(struct thread *thread) flush_unicast(1); } - FOR_ALL_INTERFACES(ifp, linklist_node) { + FOR_ALL_INTERFACES(vrf, ifp) { babel_interface_nfo *babel_ifp = NULL; if(!if_up(ifp)) continue; @@ -449,8 +454,8 @@ babel_fill_with_next_timeout(struct timeval *tv) #define printIfMin(a,b,c,d) \ if (UNLIKELY(debug & BABEL_DEBUG_TIMEOUT)) {printIfMin(a,b,c,d);} + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct interface *ifp = NULL; - struct listnode *linklist_node = NULL; *tv = check_neighbours_timeout; printIfMin(tv, 0, "check_neighbours_timeout", NULL); @@ -460,7 +465,7 @@ babel_fill_with_next_timeout(struct timeval *tv) printIfMin(tv, 1, "source_expiry_time", NULL); timeval_min(tv, &resend_time); printIfMin(tv, 1, "resend_time", NULL); - FOR_ALL_INTERFACES(ifp, linklist_node) { + FOR_ALL_INTERFACES(vrf, ifp) { babel_interface_nfo *babel_ifp = NULL; if(!if_up(ifp)) continue; @@ -514,7 +519,8 @@ resize_receive_buffer(int size) if(receive_buffer == NULL) { receive_buffer = malloc(size); if(receive_buffer == NULL) { - zlog_err("malloc(receive_buffer): %s", safe_strerror(errno)); + flog_err(EC_BABEL_MEMORY, "malloc(receive_buffer): %s", + safe_strerror(errno)); return -1; } receive_buffer_size = size; @@ -522,7 +528,8 @@ resize_receive_buffer(int size) unsigned char *new; new = realloc(receive_buffer, size); if(new == NULL) { - zlog_err("realloc(receive_buffer): %s", safe_strerror(errno)); + flog_err(EC_BABEL_MEMORY, "realloc(receive_buffer): %s", + safe_strerror(errno)); return -1; } receive_buffer = new; @@ -578,10 +585,10 @@ babel_distribute_update_interface (struct interface *ifp) static void babel_distribute_update_all (struct prefix_list *notused) { + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct interface *ifp; - struct listnode *node; - for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp)) + FOR_ALL_INTERFACES (vrf, ifp) babel_distribute_update_interface (ifp); }