]> git.puffer.fish Git - matthieu/frr.git/commitdiff
eigrpd: Convert pe->destination_ipv4 to pe->destination
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 23 Aug 2017 18:19:45 +0000 (14:19 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 24 Aug 2017 12:04:20 +0000 (08:04 -0400)
Convert the destination_ipv4 to a struct prefix and just
call it destination.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
eigrpd/eigrp_dump.c
eigrpd/eigrp_interface.c
eigrpd/eigrp_packet.c
eigrpd/eigrp_reply.c
eigrpd/eigrp_structs.h
eigrpd/eigrp_topology.c
eigrpd/eigrp_update.c

index 0cb1ee5876049e6e4c65ccbe3980283d1edf1eec..74515c98cb6a23d3556a0b30bdc71e627bcb1fb3 100644 (file)
@@ -158,7 +158,7 @@ const char *eigrp_topology_ip_string(struct eigrp_prefix_entry *tn)
        static char buf[EIGRP_IF_STRING_MAXLEN] = "";
        u_int32_t ifaddr;
 
-       ifaddr = ntohl(tn->destination_ipv4->prefix.s_addr);
+       ifaddr = ntohl(tn->destination->u.prefix4.s_addr);
        snprintf(buf, EIGRP_IF_STRING_MAXLEN, "%u.%u.%u.%u",
                 (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
                 (ifaddr >> 8) & 0xff, ifaddr & 0xff);
@@ -289,11 +289,12 @@ void show_ip_eigrp_topology_header(struct vty *vty, struct eigrp *eigrp)
 void show_ip_eigrp_prefix_entry(struct vty *vty, struct eigrp_prefix_entry *tn)
 {
        struct list *successors = eigrp_topology_get_successor(tn);
+       char buffer[PREFIX_STRLEN];
 
        vty_out(vty, "%-3c", (tn->state > 0) ? 'A' : 'P');
 
-       vty_out(vty, "%s/%u, ", inet_ntoa(tn->destination_ipv4->prefix),
-               tn->destination_ipv4->prefixlen);
+       vty_out(vty, "%s, ",
+               prefix2str(tn->destination, buffer, PREFIX_STRLEN));
        vty_out(vty, "%u successors, ", successors->count);
        vty_out(vty, "FD is %u, serno: %" PRIu64 " \n", tn->fdistance,
                tn->serno);
index 207001778d26b2f91ba556f87b22568d2e1e3c8a..bc9172dee63fa9c088df98f885ef9fe248245357 100644 (file)
@@ -289,21 +289,20 @@ int eigrp_if_up(struct eigrp_interface *ei)
        ne->adv_router = eigrp->neighbor_self;
        ne->flags = EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG;
 
-       struct prefix_ipv4 dest_addr;
+       struct prefix dest_addr;
 
        dest_addr.family = AF_INET;
-       dest_addr.prefix = ei->connected->address->u.prefix4;
+       dest_addr.u.prefix4 = ei->connected->address->u.prefix4;
        dest_addr.prefixlen = ei->connected->address->prefixlen;
-       apply_mask_ipv4(&dest_addr);
+       apply_mask(&dest_addr);
        pe = eigrp_topology_table_lookup_ipv4(eigrp->topology_table,
-                                             &dest_addr);
+                                             (struct prefix_ipv4 *)&dest_addr);
 
        if (pe == NULL) {
                pe = eigrp_prefix_entry_new();
                pe->serno = eigrp->serno;
-               pe->destination_ipv4 = prefix_ipv4_new();
-               prefix_copy((struct prefix *)pe->destination_ipv4,
-                           (struct prefix *)&dest_addr);
+               pe->destination = (struct prefix *)prefix_ipv4_new();
+               prefix_copy(pe->destination, &dest_addr);
                pe->af = AF_INET;
                pe->nt = EIGRP_TOPOLOGY_TYPE_CONNECTED;
 
index d4e8264f20e061d76620fc9fc92178d0229145e4..68e7cdcbbe7086dcbfb43eaa93bc164ae3ade225 100644 (file)
@@ -1167,21 +1167,21 @@ u_int16_t eigrp_add_internalTLV_to_stream(struct stream *s,
        u_int16_t length;
 
        stream_putw(s, EIGRP_TLV_IPv4_INT);
-       if (pe->destination_ipv4->prefixlen <= 8) {
+       if (pe->destination->prefixlen <= 8) {
                stream_putw(s, 0x001A);
                length = 0x001A;
        }
-       if ((pe->destination_ipv4->prefixlen > 8)
-           && (pe->destination_ipv4->prefixlen <= 16)) {
+       if ((pe->destination->prefixlen > 8)
+           && (pe->destination->prefixlen <= 16)) {
                stream_putw(s, 0x001B);
                length = 0x001B;
        }
-       if ((pe->destination_ipv4->prefixlen > 16)
-           && (pe->destination_ipv4->prefixlen <= 24)) {
+       if ((pe->destination->prefixlen > 16)
+           && (pe->destination->prefixlen <= 24)) {
                stream_putw(s, 0x001C);
                length = 0x001C;
        }
-       if (pe->destination_ipv4->prefixlen > 24) {
+       if (pe->destination->prefixlen > 24) {
                stream_putw(s, 0x001D);
                length = 0x001D;
        }
@@ -1200,34 +1200,18 @@ u_int16_t eigrp_add_internalTLV_to_stream(struct stream *s,
        stream_putc(s, pe->reported_metric.tag);
        stream_putc(s, pe->reported_metric.flags);
 
-       stream_putc(s, pe->destination_ipv4->prefixlen);
+       stream_putc(s, pe->destination->prefixlen);
 
-       if (pe->destination_ipv4->prefixlen <= 8) {
-               stream_putc(s, pe->destination_ipv4->prefix.s_addr & 0xFF);
-       }
-       if ((pe->destination_ipv4->prefixlen > 8)
-           && (pe->destination_ipv4->prefixlen <= 16)) {
-               stream_putc(s, pe->destination_ipv4->prefix.s_addr & 0xFF);
-               stream_putc(s,
-                           (pe->destination_ipv4->prefix.s_addr >> 8) & 0xFF);
-       }
-       if ((pe->destination_ipv4->prefixlen > 16)
-           && (pe->destination_ipv4->prefixlen <= 24)) {
-               stream_putc(s, pe->destination_ipv4->prefix.s_addr & 0xFF);
+       stream_putc(s, pe->destination->u.prefix4.s_addr & 0xFF);
+       if (pe->destination->prefixlen > 8)
                stream_putc(s,
-                           (pe->destination_ipv4->prefix.s_addr >> 8) & 0xFF);
+                           (pe->destination->u.prefix4.s_addr >> 8) & 0xFF);
+       if (pe->destination->prefixlen > 16)
                stream_putc(s,
-                           (pe->destination_ipv4->prefix.s_addr >> 16) & 0xFF);
-       }
-       if (pe->destination_ipv4->prefixlen > 24) {
-               stream_putc(s, pe->destination_ipv4->prefix.s_addr & 0xFF);
+                           (pe->destination->u.prefix4.s_addr >> 16) & 0xFF);
+       if (pe->destination->prefixlen > 24)
                stream_putc(s,
-                           (pe->destination_ipv4->prefix.s_addr >> 8) & 0xFF);
-               stream_putc(s,
-                           (pe->destination_ipv4->prefix.s_addr >> 16) & 0xFF);
-               stream_putc(s,
-                           (pe->destination_ipv4->prefix.s_addr >> 24) & 0xFF);
-       }
+                           (pe->destination->u.prefix4.s_addr >> 24) & 0xFF);
 
        return length;
 }
index 304a1a52423e122759a98e86687870dbc57efc02..cc70d1cfee77f615e76a83ef9b494de2e1964ebd 100644 (file)
@@ -87,19 +87,19 @@ void eigrp_send_reply(struct eigrp_neighbor *nbr, struct eigrp_prefix_entry *pe)
 
        /* Check if any list fits */
        if ((alist
-            && access_list_apply(alist, (struct prefix *)pe2->destination_ipv4)
+            && access_list_apply(alist, pe2->destination)
                        == FILTER_DENY)
            || (plist
                && prefix_list_apply(plist,
-                                    (struct prefix *)pe2->destination_ipv4)
+                                    pe2->destination)
                           == PREFIX_DENY)
            || (alist_i
                && access_list_apply(alist_i,
-                                    (struct prefix *)pe2->destination_ipv4)
+                                    pe2->destination)
                           == FILTER_DENY)
            || (plist_i
                && prefix_list_apply(plist_i,
-                                    (struct prefix *)pe2->destination_ipv4)
+                                    pe2->destination)
                           == PREFIX_DENY)) {
                zlog_info("REPLY SEND: Setting Metric to max");
                pe2->reported_metric.delay = EIGRP_MAX_METRIC;
index 6bb0c5cc2b07df1256f5fc07246e0cf83647b1c0..b769774a032810ef7d23d23d43d9c8edff2f3ad6 100644 (file)
@@ -469,10 +469,7 @@ struct eigrp_prefix_entry {
        u_char af;       // address family
        u_char req_action; // required action
 
-       struct prefix_ipv4
-               *destination_ipv4; // pointer to struct with ipv4 address
-       struct prefix_ipv6
-               *destination_ipv6; // pointer to struct with ipv6 address
+       struct prefix *destination;
 
        // If network type is REMOTE_EXTERNAL, pointer will have reference to
        // its external TLV
index 3ba8c5b5fd66397141afe82bf7fbdc791db540b0..e2f47ced31f6559079efa0efe5c41a7ae1b3f809 100644 (file)
@@ -81,25 +81,18 @@ static int eigrp_prefix_entry_cmp(struct eigrp_prefix_entry *node1,
 {
        if (node1->af == AF_INET) {
                if (node2->af == AF_INET) {
-                       if (node1->destination_ipv4->prefix.s_addr
-                           < node2->destination_ipv4->prefix.s_addr) {
-                               return -1; // if it belong above node2
-                       } else {
-                               if (node1->destination_ipv4->prefix.s_addr
-                                   > node2->destination_ipv4->prefix.s_addr) {
-                                       return 1; // if it belongs under node2
-                               } else {
-                                       return 0; // same value... ERROR...in
-                                                 // case of adding same prefix
-                                                 // again
-                               }
-                       }
-               } else {
+                       if (node1->destination->u.prefix4.s_addr
+                           < node2->destination->u.prefix4.s_addr)
+                               return -1;
+                       if (node1->destination->u.prefix4.s_addr
+                           > node2->destination->u.prefix4.s_addr)
+                               return 1;
+                       else
+                               return 0;
+               } else
                        return 1;
-               }
-       } else {          // TODO check if the prefix dont exists
-               return 1; // add to end
-       }
+       } else
+               return 1;
 }
 
 /*
@@ -125,8 +118,7 @@ struct eigrp_prefix_entry *eigrp_prefix_entry_new()
        new->rij = list_new();
        new->entries->cmp = (int (*)(void *, void *))eigrp_neighbor_entry_cmp;
        new->distance = new->fdistance = new->rdistance = EIGRP_MAX_METRIC;
-       new->destination_ipv4 = NULL;
-       new->destination_ipv6 = NULL;
+       new->destination = NULL;
 
        return new;
 }
@@ -137,9 +129,8 @@ struct eigrp_prefix_entry *eigrp_prefix_entry_new()
 static int eigrp_neighbor_entry_cmp(struct eigrp_neighbor_entry *entry1,
                                    struct eigrp_neighbor_entry *entry2)
 {
-       if (entry1->distance
-           < entry2->distance) // parameter used in list_add_sort ()
-               return -1;      // actually set to sort by distance
+       if (entry1->distance < entry2->distance)
+               return -1;
        if (entry1->distance > entry2->distance)
                return 1;
 
@@ -205,7 +196,8 @@ void eigrp_neighbor_entry_add(struct eigrp_prefix_entry *node,
                listnode_add_sort(node->entries, entry);
                entry->prefix = node;
 
-               eigrp_zebra_route_add(node->destination_ipv4, l);
+               eigrp_zebra_route_add((struct prefix_ipv4 *)
+                                     node->destination, l);
        }
 
        list_delete(l);
@@ -230,7 +222,8 @@ void eigrp_prefix_entry_delete(struct list *topology,
                list_free(node->entries);
                list_free(node->rij);
                listnode_delete(topology, node);
-               eigrp_zebra_route_delete(node->destination_ipv4);
+               eigrp_zebra_route_delete((struct prefix_ipv4 *)
+                                        node->destination);
                XFREE(MTYPE_EIGRP_PREFIX_ENTRY, node);
        }
 }
@@ -243,7 +236,8 @@ void eigrp_neighbor_entry_delete(struct eigrp_prefix_entry *node,
 {
        if (listnode_lookup(node->entries, entry) != NULL) {
                listnode_delete(node->entries, entry);
-               eigrp_zebra_route_delete(node->destination_ipv4);
+               eigrp_zebra_route_delete((struct prefix_ipv4 *)
+                                        node->destination);
                XFREE(MTYPE_EIGRP_NEIGHBOR_ENTRY, entry);
        }
 }
@@ -275,11 +269,8 @@ eigrp_topology_table_lookup_ipv4(struct list *topology_table,
        struct eigrp_prefix_entry *data;
        struct listnode *node;
        for (ALL_LIST_ELEMENTS_RO(topology_table, node, data)) {
-               if ((data->af == AF_INET)
-                   && (data->destination_ipv4->prefix.s_addr
-                       == address->prefix.s_addr)
-                   && (data->destination_ipv4->prefixlen
-                       == address->prefixlen))
+               if (prefix_same(data->destination,
+                               (struct prefix *)address))
                        return data;
        }
 
@@ -476,13 +467,16 @@ void eigrp_update_routing_table(struct eigrp_prefix_entry *prefix)
        struct eigrp_neighbor_entry *entry;
 
        if (successors) {
-               eigrp_zebra_route_add(prefix->destination_ipv4, successors);
+               eigrp_zebra_route_add((struct prefix_ipv4 *)
+                                     prefix->destination,
+                                     successors);
                for (ALL_LIST_ELEMENTS_RO(successors, node, entry))
                        entry->flags |= EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG;
 
                list_delete(successors);
        } else {
-               eigrp_zebra_route_delete(prefix->destination_ipv4);
+               eigrp_zebra_route_delete((struct prefix_ipv4 *)
+                                        prefix->destination);
                for (ALL_LIST_ELEMENTS_RO(prefix->entries, node, entry))
                        entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG;
        }
index e4b7883741045c2c61e9bb171e2eedcc0ca8f3e8..c59a010087e65251254c082e6a2eba19fb9aaf33 100644 (file)
@@ -116,9 +116,10 @@ static void eigrp_update_receive_GR_ask(struct eigrp *eigrp,
 
        /* iterate over all prefixes which weren't advertised by neighbor */
        for (ALL_LIST_ELEMENTS_RO(nbr_prefixes, node1, prefix)) {
-               zlog_debug("GR receive: Neighbor not advertised %s/%d",
-                          inet_ntoa(prefix->destination_ipv4->prefix),
-                          prefix->destination_ipv4->prefixlen);
+               char buffer[PREFIX_STRLEN];
+               zlog_debug("GR receive: Neighbor not advertised %s",
+                          prefix2str(prefix->destination,
+                                     buffer, PREFIX_STRLEN));
 
                fsm_msg.metrics = prefix->reported_metric;
                /* set delay to MAX */
@@ -311,9 +312,8 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph,
                                /*Here comes topology information save*/
                                pe = eigrp_prefix_entry_new();
                                pe->serno = eigrp->serno;
-                               pe->destination_ipv4 = prefix_ipv4_new();
-                               prefix_copy(
-                                       (struct prefix *)pe->destination_ipv4,
+                               pe->destination = (struct prefix *)prefix_ipv4_new();
+                               prefix_copy(pe->destination,
                                        (struct prefix *)&dest_addr);
                                pe->af = AF_INET;
                                pe->state = EIGRP_FSM_STATE_PASSIVE;
@@ -571,7 +571,7 @@ void eigrp_update_send_EOT(struct eigrp_neighbor *nbr)
        struct access_list *alist_i;
        struct prefix_list *plist_i;
        struct eigrp *e;
-       struct prefix_ipv4 *dest_addr;
+       struct prefix *dest_addr;
        u_int32_t seq_no = nbr->ei->eigrp->sequence_number;
 
        ep = eigrp_packet_new(nbr->ei->ifp->mtu, nbr);
@@ -609,7 +609,7 @@ void eigrp_update_send_EOT(struct eigrp_neighbor *nbr)
                                }
                        }
                        /* Get destination address from prefix */
-                       dest_addr = pe->destination_ipv4;
+                       dest_addr = pe->destination;
 
                        /*
                         * Filtering
@@ -656,7 +656,7 @@ void eigrp_update_send(struct eigrp_interface *ei)
        struct access_list *alist_i;
        struct prefix_list *plist_i;
        struct eigrp *e;
-       struct prefix_ipv4 *dest_addr;
+       struct prefix *dest_addr;
        u_int32_t seq_no = ei->eigrp->sequence_number;
 
        if (ei->nbrs->count == 0)
@@ -714,7 +714,7 @@ void eigrp_update_send(struct eigrp_interface *ei)
                        has_tlv = 0;
                }
                /* Get destination address from prefix */
-               dest_addr = pe->destination_ipv4;
+               dest_addr = pe->destination;
 
                /*
                 * Filtering
@@ -824,7 +824,7 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr)
        u_int16_t length = EIGRP_HEADER_LEN;
        struct listnode *node, *nnode;
        struct eigrp_prefix_entry *pe;
-       struct prefix_ipv4 *dest_addr;
+       struct prefix *dest_addr;
        struct eigrp *e;
        struct access_list *alist, *alist_i;
        struct prefix_list *plist, *plist_i;
@@ -887,7 +887,7 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr)
                /*
                 * Filtering
                 */
-               dest_addr = pe->destination_ipv4;
+               dest_addr = pe->destination;
                /* get list from eigrp process */
                e = eigrp_lookup();
                /* Get access-lists and prefix-lists from process and interface
@@ -899,22 +899,20 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr)
 
                /* Check if any list fits */
                if ((alist
-                    && access_list_apply(alist, (struct prefix *)dest_addr)
+                    && access_list_apply(alist, dest_addr)
                                == FILTER_DENY)
                    || (plist
-                       && prefix_list_apply(plist, (struct prefix *)dest_addr)
+                       && prefix_list_apply(plist, dest_addr)
                                   == PREFIX_DENY)
                    || (alist_i
-                       && access_list_apply(alist_i,
-                                            (struct prefix *)dest_addr)
+                       && access_list_apply(alist_i, dest_addr)
                                   == FILTER_DENY)
                    || (plist_i
-                       && prefix_list_apply(plist_i,
-                                            (struct prefix *)dest_addr)
+                       && prefix_list_apply(plist_i, dest_addr)
                                   == PREFIX_DENY)) {
                        /* do not send filtered route */
                        zlog_info("Filtered prefix %s won't be sent out.",
-                                 inet_ntoa(dest_addr->prefix));
+                                 inet_ntoa(dest_addr->u.prefix4));
                } else {
                        /* sending route which wasn't filtered */
                        length += eigrp_add_internalTLV_to_stream(ep->s, pe);
@@ -928,22 +926,20 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr)
 
                /* Check if any list fits */
                if ((alist
-                    && access_list_apply(alist, (struct prefix *)dest_addr)
+                    && access_list_apply(alist, dest_addr)
                                == FILTER_DENY)
                    || (plist
-                       && prefix_list_apply(plist, (struct prefix *)dest_addr)
+                       && prefix_list_apply(plist, dest_addr)
                                   == PREFIX_DENY)
                    || (alist_i
-                       && access_list_apply(alist_i,
-                                            (struct prefix *)dest_addr)
+                       && access_list_apply(alist_i, dest_addr)
                                   == FILTER_DENY)
                    || (plist_i
-                       && prefix_list_apply(plist_i,
-                                            (struct prefix *)dest_addr)
+                       && prefix_list_apply(plist_i, dest_addr)
                                   == PREFIX_DENY)) {
                        /* do not send filtered route */
                        zlog_info("Filtered prefix %s will be removed.",
-                                 inet_ntoa(dest_addr->prefix));
+                                 inet_ntoa(dest_addr->u.prefix4));
 
                        /* prepare message for FSM */
                        struct eigrp_fsm_action_message fsm_msg;