diff options
Diffstat (limited to 'eigrpd')
-rw-r--r-- | eigrpd/eigrp_const.h | 8 | ||||
-rw-r--r-- | eigrpd/eigrp_dump.c | 4 | ||||
-rw-r--r-- | eigrpd/eigrp_dump.h | 4 | ||||
-rw-r--r-- | eigrpd/eigrp_fsm.c | 38 | ||||
-rw-r--r-- | eigrpd/eigrp_interface.c | 10 | ||||
-rw-r--r-- | eigrpd/eigrp_memory.c | 2 | ||||
-rw-r--r-- | eigrpd/eigrp_memory.h | 2 | ||||
-rw-r--r-- | eigrpd/eigrp_neighbor.c | 2 | ||||
-rw-r--r-- | eigrpd/eigrp_neighbor.h | 2 | ||||
-rw-r--r-- | eigrpd/eigrp_network.c | 2 | ||||
-rw-r--r-- | eigrpd/eigrp_network.h | 2 | ||||
-rw-r--r-- | eigrpd/eigrp_packet.h | 4 | ||||
-rw-r--r-- | eigrpd/eigrp_reply.c | 95 | ||||
-rw-r--r-- | eigrpd/eigrp_routemap.h | 6 | ||||
-rw-r--r-- | eigrpd/eigrp_siaquery.c | 2 | ||||
-rw-r--r-- | eigrpd/eigrp_siareply.c | 2 | ||||
-rw-r--r-- | eigrpd/eigrp_structs.h | 4 | ||||
-rw-r--r-- | eigrpd/eigrp_topology.c | 66 | ||||
-rw-r--r-- | eigrpd/eigrp_topology.h | 12 | ||||
-rw-r--r-- | eigrpd/eigrp_update.c | 307 | ||||
-rw-r--r-- | eigrpd/eigrp_vty.c | 12 | ||||
-rw-r--r-- | eigrpd/eigrp_zebra.c | 2 |
22 files changed, 212 insertions, 376 deletions
diff --git a/eigrpd/eigrp_const.h b/eigrpd/eigrp_const.h index a008891a5..3fa59756b 100644 --- a/eigrpd/eigrp_const.h +++ b/eigrpd/eigrp_const.h @@ -130,10 +130,10 @@ enum metric_change { #define EIGRP_TOPOLOGY_TYPE_REMOTE_EXTERNAL 2 // Remote external network /*EIGRP TT entry flags*/ -#define EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG (1 << 0) -#define EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG (1 << 1) -#define EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG (1 << 2) -#define EIGRP_NEIGHBOR_ENTRY_EXTERNAL_FLAG (1 << 3) +#define EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG (1 << 0) +#define EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG (1 << 1) +#define EIGRP_NEXTHOP_ENTRY_INTABLE_FLAG (1 << 2) +#define EIGRP_NEXTHOP_ENTRY_EXTERNAL_FLAG (1 << 3) /*EIGRP FSM state count, event count*/ #define EIGRP_FSM_STATE_MAX 5 diff --git a/eigrpd/eigrp_dump.c b/eigrpd/eigrp_dump.c index 98c72668f..091b27112 100644 --- a/eigrpd/eigrp_dump.c +++ b/eigrpd/eigrp_dump.c @@ -304,8 +304,8 @@ void show_ip_eigrp_prefix_entry(struct vty *vty, struct eigrp_prefix_entry *tn) list_delete(successors); } -void show_ip_eigrp_neighbor_entry(struct vty *vty, struct eigrp *eigrp, - struct eigrp_neighbor_entry *te, int *first) +void show_ip_eigrp_nexthop_entry(struct vty *vty, struct eigrp *eigrp, + struct eigrp_nexthop_entry *te, int *first) { if (te->reported_distance == EIGRP_MAX_METRIC) return; diff --git a/eigrpd/eigrp_dump.h b/eigrpd/eigrp_dump.h index 7f9381595..cda304ba6 100644 --- a/eigrpd/eigrp_dump.h +++ b/eigrpd/eigrp_dump.h @@ -156,8 +156,8 @@ extern void show_ip_eigrp_neighbor_sub(struct vty *, struct eigrp_neighbor *, int); extern void show_ip_eigrp_prefix_entry(struct vty *, struct eigrp_prefix_entry *); -extern void show_ip_eigrp_neighbor_entry(struct vty *, struct eigrp *, - struct eigrp_neighbor_entry *, int *); +extern void show_ip_eigrp_nexthop_entry(struct vty *, struct eigrp *, + struct eigrp_nexthop_entry *, int *); extern void eigrp_debug_init(void); diff --git a/eigrpd/eigrp_fsm.c b/eigrpd/eigrp_fsm.c index 47cd112cf..4514e5b9a 100644 --- a/eigrpd/eigrp_fsm.c +++ b/eigrpd/eigrp_fsm.c @@ -183,12 +183,12 @@ static int eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg) // Loading base information from message // struct eigrp *eigrp = msg->eigrp; struct eigrp_prefix_entry *prefix = msg->prefix; - struct eigrp_neighbor_entry *entry = msg->entry; + struct eigrp_nexthop_entry *entry = msg->entry; u_char actual_state = prefix->state; enum metric_change change; if (entry == NULL) { - entry = eigrp_neighbor_entry_new(); + entry = eigrp_nexthop_entry_new(); entry->adv_router = msg->adv_router; entry->ei = msg->adv_router->ei; entry->prefix = prefix; @@ -203,7 +203,7 @@ static int eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg) switch (actual_state) { case EIGRP_FSM_STATE_PASSIVE: { - struct eigrp_neighbor_entry *head = + struct eigrp_nexthop_entry *head = listnode_head(prefix->entries); if (head->reported_distance < prefix->fdistance) { @@ -224,7 +224,7 @@ static int eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg) } case EIGRP_FSM_STATE_ACTIVE_0: { if (msg->packet_type == EIGRP_OPC_REPLY) { - struct eigrp_neighbor_entry *head = + struct eigrp_nexthop_entry *head = listnode_head(prefix->entries); listnode_delete(prefix->rij, entry->adv_router); @@ -240,7 +240,7 @@ static int eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg) return EIGRP_FSM_EVENT_LR_FCN; } else if (msg->packet_type == EIGRP_OPC_QUERY && (entry->flags - & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG)) { + & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) { return EIGRP_FSM_EVENT_QACT; } @@ -250,14 +250,14 @@ static int eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg) } case EIGRP_FSM_STATE_ACTIVE_1: { if (msg->packet_type == EIGRP_OPC_QUERY - && (entry->flags & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG)) { + && (entry->flags & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) { return EIGRP_FSM_EVENT_QACT; } else if (msg->packet_type == EIGRP_OPC_REPLY) { listnode_delete(prefix->rij, entry->adv_router); if (change == METRIC_INCREASE && (entry->flags - & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG)) { + & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) { return EIGRP_FSM_EVENT_DINC; } else if (prefix->rij->count) { return EIGRP_FSM_KEEP_STATE; @@ -267,7 +267,7 @@ static int eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg) } } else if (msg->packet_type == EIGRP_OPC_UPDATE && change == 1 && (entry->flags - & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG)) { + & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) { return EIGRP_FSM_EVENT_DINC; } return EIGRP_FSM_KEEP_STATE; @@ -276,7 +276,7 @@ static int eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg) } case EIGRP_FSM_STATE_ACTIVE_2: { if (msg->packet_type == EIGRP_OPC_REPLY) { - struct eigrp_neighbor_entry *head = + struct eigrp_nexthop_entry *head = listnode_head(prefix->entries); listnode_delete(prefix->rij, entry->adv_router); @@ -302,7 +302,7 @@ static int eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg) if (change == METRIC_INCREASE && (entry->flags - & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG)) { + & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) { return EIGRP_FSM_EVENT_DINC; } else if (prefix->rij->count) { return EIGRP_FSM_KEEP_STATE; @@ -312,7 +312,7 @@ static int eigrp_get_fsm_event(struct eigrp_fsm_action_message *msg) } } else if (msg->packet_type == EIGRP_OPC_UPDATE && change == 1 && (entry->flags - & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG)) { + & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG)) { return EIGRP_FSM_EVENT_DINC; } return EIGRP_FSM_KEEP_STATE; @@ -348,7 +348,7 @@ int eigrp_fsm_event_nq_fcn(struct eigrp_fsm_action_message *msg) struct eigrp *eigrp = msg->eigrp; struct eigrp_prefix_entry *prefix = msg->prefix; struct list *successors = eigrp_topology_get_successor(prefix); - struct eigrp_neighbor_entry *ne; + struct eigrp_nexthop_entry *ne; assert(successors); // If this is NULL we have shit the bed, fun huh? @@ -376,7 +376,7 @@ int eigrp_fsm_event_q_fcn(struct eigrp_fsm_action_message *msg) struct eigrp *eigrp = msg->eigrp; struct eigrp_prefix_entry *prefix = msg->prefix; struct list *successors = eigrp_topology_get_successor(prefix); - struct eigrp_neighbor_entry *ne; + struct eigrp_nexthop_entry *ne; assert(successors); // If this is NULL somebody poked us in the eye. @@ -401,7 +401,7 @@ int eigrp_fsm_event_q_fcn(struct eigrp_fsm_action_message *msg) int eigrp_fsm_event_keep_state(struct eigrp_fsm_action_message *msg) { struct eigrp_prefix_entry *prefix = msg->prefix; - struct eigrp_neighbor_entry *ne = listnode_head(prefix->entries); + struct eigrp_nexthop_entry *ne = listnode_head(prefix->entries); if (prefix->state == EIGRP_FSM_STATE_PASSIVE) { if (!eigrp_metrics_is_same(prefix->reported_metric, @@ -431,7 +431,7 @@ int eigrp_fsm_event_lr(struct eigrp_fsm_action_message *msg) { struct eigrp *eigrp = msg->eigrp; struct eigrp_prefix_entry *prefix = msg->prefix; - struct eigrp_neighbor_entry *ne = listnode_head(prefix->entries); + struct eigrp_nexthop_entry *ne = listnode_head(prefix->entries); prefix->fdistance = prefix->distance = prefix->rdistance = ne->distance; @@ -461,7 +461,7 @@ int eigrp_fsm_event_lr(struct eigrp_fsm_action_message *msg) int eigrp_fsm_event_dinc(struct eigrp_fsm_action_message *msg) { struct list *successors = eigrp_topology_get_successor(msg->prefix); - struct eigrp_neighbor_entry *ne; + struct eigrp_nexthop_entry *ne; assert(successors); // Trump and his big hands @@ -483,7 +483,7 @@ int eigrp_fsm_event_lr_fcs(struct eigrp_fsm_action_message *msg) { struct eigrp *eigrp = msg->eigrp; struct eigrp_prefix_entry *prefix = msg->prefix; - struct eigrp_neighbor_entry *ne = listnode_head(prefix->entries); + struct eigrp_nexthop_entry *ne = listnode_head(prefix->entries); prefix->state = EIGRP_FSM_STATE_PASSIVE; prefix->distance = prefix->rdistance = ne->distance; @@ -515,7 +515,7 @@ int eigrp_fsm_event_lr_fcn(struct eigrp_fsm_action_message *msg) { struct eigrp *eigrp = msg->eigrp; struct eigrp_prefix_entry *prefix = msg->prefix; - struct eigrp_neighbor_entry *best_successor; + struct eigrp_nexthop_entry *best_successor; struct list *successors = eigrp_topology_get_successor(prefix); assert(successors); // Routing without a stack @@ -544,7 +544,7 @@ int eigrp_fsm_event_lr_fcn(struct eigrp_fsm_action_message *msg) int eigrp_fsm_event_qact(struct eigrp_fsm_action_message *msg) { struct list *successors = eigrp_topology_get_successor(msg->prefix); - struct eigrp_neighbor_entry *ne; + struct eigrp_nexthop_entry *ne; assert(successors); // Cats and no Dogs diff --git a/eigrpd/eigrp_interface.c b/eigrpd/eigrp_interface.c index ee3e2217b..f2512eada 100644 --- a/eigrpd/eigrp_interface.c +++ b/eigrpd/eigrp_interface.c @@ -245,7 +245,7 @@ struct eigrp_if_params *eigrp_lookup_if_params(struct interface *ifp, int eigrp_if_up(struct eigrp_interface *ei) { struct eigrp_prefix_entry *pe; - struct eigrp_neighbor_entry *ne; + struct eigrp_nexthop_entry *ne; struct eigrp_metrics metric; struct eigrp_interface *ei2; struct listnode *node, *nnode; @@ -279,14 +279,14 @@ int eigrp_if_up(struct eigrp_interface *ei) /*Add connected entry to topology table*/ - ne = eigrp_neighbor_entry_new(); + ne = eigrp_nexthop_entry_new(); ne->ei = ei; ne->reported_metric = metric; ne->total_metric = metric; ne->distance = eigrp_calculate_metrics(eigrp, metric); ne->reported_distance = 0; ne->adv_router = eigrp->neighbor_self; - ne->flags = EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG; + ne->flags = EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG; struct prefix dest_addr; @@ -313,7 +313,7 @@ int eigrp_if_up(struct eigrp_interface *ei) eigrp_prefix_entry_add(eigrp->topology_table, pe); listnode_add(eigrp->topology_changes_internalIPV4, pe); - eigrp_neighbor_entry_add(pe, ne); + eigrp_nexthop_entry_add(pe, ne); for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, ei2)) { eigrp_update_send(ei2); @@ -325,7 +325,7 @@ int eigrp_if_up(struct eigrp_interface *ei) struct eigrp_fsm_action_message msg; ne->prefix = pe; - eigrp_neighbor_entry_add(pe, ne); + eigrp_nexthop_entry_add(pe, ne); msg.packet_type = EIGRP_OPC_UPDATE; msg.eigrp = eigrp; diff --git a/eigrpd/eigrp_memory.c b/eigrpd/eigrp_memory.c index a8f603d2e..85b14c28c 100644 --- a/eigrpd/eigrp_memory.c +++ b/eigrpd/eigrp_memory.c @@ -38,5 +38,5 @@ DEFINE_MTYPE(EIGRPD, EIGRP_SEQ_TLV, "EIGRP SEQ TLV") DEFINE_MTYPE(EIGRPD, EIGRP_AUTH_TLV, "EIGRP AUTH TLV") DEFINE_MTYPE(EIGRPD, EIGRP_AUTH_SHA256_TLV, "EIGRP SHA TLV") DEFINE_MTYPE(EIGRPD, EIGRP_PREFIX_ENTRY, "EIGRP Prefix") -DEFINE_MTYPE(EIGRPD, EIGRP_NEIGHBOR_ENTRY, "EIGRP Neighbor Entry") +DEFINE_MTYPE(EIGRPD, EIGRP_NEXTHOP_ENTRY, "EIGRP Nexthop Entry") DEFINE_MTYPE(EIGRPD, EIGRP_FSM_MSG, "EIGRP FSM Message") diff --git a/eigrpd/eigrp_memory.h b/eigrpd/eigrp_memory.h index b8c85a49b..e4d02c09d 100644 --- a/eigrpd/eigrp_memory.h +++ b/eigrpd/eigrp_memory.h @@ -37,7 +37,7 @@ DECLARE_MTYPE(EIGRP_SEQ_TLV) DECLARE_MTYPE(EIGRP_AUTH_TLV) DECLARE_MTYPE(EIGRP_AUTH_SHA256_TLV) DECLARE_MTYPE(EIGRP_PREFIX_ENTRY) -DECLARE_MTYPE(EIGRP_NEIGHBOR_ENTRY) +DECLARE_MTYPE(EIGRP_NEXTHOP_ENTRY) DECLARE_MTYPE(EIGRP_FSM_MSG) #endif /* _FRR_EIGRP_MEMORY_H */ diff --git a/eigrpd/eigrp_neighbor.c b/eigrpd/eigrp_neighbor.c index 5d78dc375..b7b336949 100644 --- a/eigrpd/eigrp_neighbor.c +++ b/eigrpd/eigrp_neighbor.c @@ -358,7 +358,7 @@ void eigrp_nbr_hard_restart(struct eigrp_neighbor *nbr, struct vty *vty) eigrp_nbr_delete(nbr); } -int eigrp_nbr_split_horizon_check(struct eigrp_neighbor_entry *ne, struct eigrp_interface *ei) +int eigrp_nbr_split_horizon_check(struct eigrp_nexthop_entry *ne, struct eigrp_interface *ei) { if (ne->distance == EIGRP_MAX_METRIC) return 0; diff --git a/eigrpd/eigrp_neighbor.h b/eigrpd/eigrp_neighbor.h index 6467fb24a..b939e25e5 100644 --- a/eigrpd/eigrp_neighbor.h +++ b/eigrpd/eigrp_neighbor.h @@ -53,6 +53,6 @@ extern struct eigrp_neighbor *eigrp_nbr_lookup_by_addr_process(struct eigrp *, struct in_addr); extern void eigrp_nbr_hard_restart(struct eigrp_neighbor *nbr, struct vty *vty); -extern int eigrp_nbr_split_horizon_check(struct eigrp_neighbor_entry *ne, +extern int eigrp_nbr_split_horizon_check(struct eigrp_nexthop_entry *ne, struct eigrp_interface *ei); #endif /* _ZEBRA_EIGRP_NEIGHBOR_H */ diff --git a/eigrpd/eigrp_network.c b/eigrpd/eigrp_network.c index 0cf5bd9ba..c5f408031 100644 --- a/eigrpd/eigrp_network.c +++ b/eigrpd/eigrp_network.c @@ -413,7 +413,7 @@ u_int32_t eigrp_calculate_metrics(struct eigrp *eigrp, } u_int32_t eigrp_calculate_total_metrics(struct eigrp *eigrp, - struct eigrp_neighbor_entry *entry) + struct eigrp_nexthop_entry *entry) { entry->total_metric = entry->reported_metric; uint64_t temp_delay = (uint64_t)entry->total_metric.delay diff --git a/eigrpd/eigrp_network.h b/eigrpd/eigrp_network.h index 6ddd57eee..77bd1416f 100644 --- a/eigrpd/eigrp_network.h +++ b/eigrpd/eigrp_network.h @@ -45,7 +45,7 @@ extern void eigrp_adjust_sndbuflen(struct eigrp *, unsigned int); extern u_int32_t eigrp_calculate_metrics(struct eigrp *, struct eigrp_metrics); extern u_int32_t eigrp_calculate_total_metrics(struct eigrp *, - struct eigrp_neighbor_entry *); + struct eigrp_nexthop_entry *); extern u_char eigrp_metrics_is_same(struct eigrp_metrics, struct eigrp_metrics); extern void eigrp_external_routes_refresh(struct eigrp *, int); diff --git a/eigrpd/eigrp_packet.h b/eigrpd/eigrp_packet.h index e52fd268f..a7d510218 100644 --- a/eigrpd/eigrp_packet.h +++ b/eigrpd/eigrp_packet.h @@ -83,6 +83,10 @@ extern int eigrp_hello_timer(struct thread *); /* * These externs are found in eigrp_update.c */ +extern bool eigrp_update_prefix_apply(struct eigrp *eigrp, + struct eigrp_interface *ei, + int in, + struct prefix *prefix); extern void eigrp_update_send(struct eigrp_interface *); extern void eigrp_update_receive(struct eigrp *, struct ip *, struct eigrp_header *, struct stream *, diff --git a/eigrpd/eigrp_reply.c b/eigrpd/eigrp_reply.c index 2b5b0aa44..11e6e855c 100644 --- a/eigrpd/eigrp_reply.c +++ b/eigrpd/eigrp_reply.c @@ -64,43 +64,20 @@ void eigrp_send_reply(struct eigrp_neighbor *nbr, struct eigrp_prefix_entry *pe) { struct eigrp_packet *ep; u_int16_t length = EIGRP_HEADER_LEN; - - struct access_list *alist; - struct prefix_list *plist; - struct access_list *alist_i; - struct prefix_list *plist_i; - struct eigrp *e; + struct eigrp_interface *ei = nbr->ei; + struct eigrp *eigrp = ei->eigrp; struct eigrp_prefix_entry *pe2; // TODO: Work in progress /* Filtering */ /* get list from eigrp process */ - e = eigrp_lookup(); pe2 = XCALLOC(MTYPE_EIGRP_PREFIX_ENTRY, sizeof(struct eigrp_prefix_entry)); memcpy(pe2, pe, sizeof(struct eigrp_prefix_entry)); - /* Get access-lists and prefix-lists from process and interface */ - alist = e->list[EIGRP_FILTER_OUT]; - plist = e->prefix[EIGRP_FILTER_OUT]; - alist_i = nbr->ei->list[EIGRP_FILTER_OUT]; - plist_i = nbr->ei->prefix[EIGRP_FILTER_OUT]; - - /* Check if any list fits */ - if ((alist - && access_list_apply(alist, pe2->destination) - == FILTER_DENY) - || (plist - && prefix_list_apply(plist, - pe2->destination) - == PREFIX_DENY) - || (alist_i - && access_list_apply(alist_i, - pe2->destination) - == FILTER_DENY) - || (plist_i - && prefix_list_apply(plist_i, - pe2->destination) - == PREFIX_DENY)) { + + if (eigrp_update_prefix_apply(eigrp, ei, + EIGRP_FILTER_OUT, + pe2->destination)) { zlog_info("REPLY SEND: Setting Metric to max"); pe2->reported_metric.delay = EIGRP_MAX_METRIC; @@ -110,34 +87,34 @@ void eigrp_send_reply(struct eigrp_neighbor *nbr, struct eigrp_prefix_entry *pe) * End of filtering */ - ep = eigrp_packet_new(nbr->ei->ifp->mtu, nbr); + ep = eigrp_packet_new(ei->ifp->mtu, nbr); /* Prepare EIGRP INIT UPDATE header */ - eigrp_packet_header_init(EIGRP_OPC_REPLY, e, ep->s, 0, - nbr->ei->eigrp->sequence_number, 0); + eigrp_packet_header_init(EIGRP_OPC_REPLY, eigrp, ep->s, 0, + eigrp->sequence_number, 0); // encode Authentication TLV, if needed - if ((IF_DEF_PARAMS(nbr->ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) - && (IF_DEF_PARAMS(nbr->ei->ifp)->auth_keychain != NULL)) { - length += eigrp_add_authTLV_MD5_to_stream(ep->s, nbr->ei); + if ((IF_DEF_PARAMS(ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) + && (IF_DEF_PARAMS(ei->ifp)->auth_keychain != NULL)) { + length += eigrp_add_authTLV_MD5_to_stream(ep->s, ei); } length += eigrp_add_internalTLV_to_stream(ep->s, pe2); - if ((IF_DEF_PARAMS(nbr->ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) - && (IF_DEF_PARAMS(nbr->ei->ifp)->auth_keychain != NULL)) { - eigrp_make_md5_digest(nbr->ei, ep->s, EIGRP_AUTH_UPDATE_FLAG); + if ((IF_DEF_PARAMS(ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) + && (IF_DEF_PARAMS(ei->ifp)->auth_keychain != NULL)) { + eigrp_make_md5_digest(ei, ep->s, EIGRP_AUTH_UPDATE_FLAG); } /* EIGRP Checksum */ - eigrp_packet_checksum(nbr->ei, ep->s, length); + eigrp_packet_checksum(ei, ep->s, length); ep->length = length; ep->dst.s_addr = nbr->src.s_addr; /*This ack number we await from neighbor*/ - ep->sequence_number = nbr->ei->eigrp->sequence_number; + ep->sequence_number = eigrp->sequence_number; /*Put packet to retransmission queue*/ eigrp_fifo_push(nbr->retrans_queue, ep); @@ -157,12 +134,6 @@ void eigrp_reply_receive(struct eigrp *eigrp, struct ip *iph, struct eigrp_neighbor *nbr; struct TLV_IPv4_Internal_type *tlv; - struct access_list *alist; - struct prefix_list *plist; - struct access_list *alist_i; - struct prefix_list *plist_i; - struct eigrp *e; - u_int16_t type; /* increment statistics. */ @@ -200,35 +171,9 @@ void eigrp_reply_receive(struct eigrp *eigrp, struct ip *iph, struct eigrp_neighbor_entry *entry = eigrp_prefix_entry_lookup(dest->entries, nbr); - /* - * Filtering - */ - // TODO: Work in progress - /* get list from eigrp process */ - e = eigrp_lookup(); - /* Get access-lists and prefix-lists from process and - * interface */ - alist = e->list[EIGRP_FILTER_IN]; - plist = e->prefix[EIGRP_FILTER_IN]; - alist_i = ei->list[EIGRP_FILTER_IN]; - plist_i = ei->prefix[EIGRP_FILTER_IN]; - /* Check if any list fits */ - if ((alist - && access_list_apply(alist, - (struct prefix *)&dest_addr) - == FILTER_DENY) - || (plist - && prefix_list_apply( - plist, (struct prefix *)&dest_addr) - == PREFIX_DENY) - || (alist_i - && access_list_apply( - alist_i, (struct prefix *)&dest_addr) - == FILTER_DENY) - || (plist_i - && prefix_list_apply( - plist_i, (struct prefix *)&dest_addr) - == PREFIX_DENY)) { + if (eigrp_update_prefix_apply(eigrp, ei, + EIGRP_FILTER_IN, + &dest_addr)) { tlv->metric.delay = EIGRP_MAX_METRIC; } /* diff --git a/eigrpd/eigrp_routemap.h b/eigrpd/eigrp_routemap.h index f378d88cd..1d37b25ef 100644 --- a/eigrpd/eigrp_routemap.h +++ b/eigrpd/eigrp_routemap.h @@ -8,6 +8,12 @@ #ifndef EIGRPD_EIGRP_ROUTEMAP_H_ #define EIGRPD_EIGRP_ROUTEMAP_H_ +#include "if_rmap.h" + +extern bool eigrp_routemap_prefix_apply(struct eigrp *eigrp, + struct eigrp_interface *ei, + int in, + struct prefix *prefix); extern void eigrp_route_map_update(const char *); extern void eigrp_route_map_init(); extern void eigrp_if_rmap_update(struct if_rmap *); diff --git a/eigrpd/eigrp_siaquery.c b/eigrpd/eigrp_siaquery.c index 7264e53b6..b242bcaae 100644 --- a/eigrpd/eigrp_siaquery.c +++ b/eigrpd/eigrp_siaquery.c @@ -95,7 +95,7 @@ void eigrp_siaquery_receive(struct eigrp *eigrp, struct ip *iph, * know)*/ if (dest != NULL) { struct eigrp_fsm_action_message msg; - struct eigrp_neighbor_entry *entry = + struct eigrp_nexthop_entry *entry = eigrp_prefix_entry_lookup(dest->entries, nbr); msg.packet_type = EIGRP_OPC_SIAQUERY; diff --git a/eigrpd/eigrp_siareply.c b/eigrpd/eigrp_siareply.c index 8496c0567..4998a2d54 100644 --- a/eigrpd/eigrp_siareply.c +++ b/eigrpd/eigrp_siareply.c @@ -94,7 +94,7 @@ void eigrp_siareply_receive(struct eigrp *eigrp, struct ip *iph, * know)*/ if (dest != NULL) { struct eigrp_fsm_action_message msg; - struct eigrp_neighbor_entry *entry = + struct eigrp_nexthop_entry *entry = eigrp_prefix_entry_lookup(dest->entries, nbr); msg.packet_type = EIGRP_OPC_SIAQUERY; diff --git a/eigrpd/eigrp_structs.h b/eigrpd/eigrp_structs.h index b769774a0..5bc63a7c4 100644 --- a/eigrpd/eigrp_structs.h +++ b/eigrpd/eigrp_structs.h @@ -480,7 +480,7 @@ struct eigrp_prefix_entry { }; /* EIGRP Topology table record structure */ -struct eigrp_neighbor_entry { +struct eigrp_nexthop_entry { struct eigrp_prefix_entry *prefix; u_int32_t reported_distance; // distance reported by neighbor u_int32_t distance; // sum of reported distance and link cost to @@ -508,7 +508,7 @@ struct eigrp_fsm_action_message { u_char packet_type; // UPDATE, QUERY, SIAQUERY, SIAREPLY struct eigrp *eigrp; // which thread sent mesg struct eigrp_neighbor *adv_router; // advertising neighbor - struct eigrp_neighbor_entry *entry; + struct eigrp_nexthop_entry *entry; struct eigrp_prefix_entry *prefix; msg_data_t data_type; // internal or external tlv type struct eigrp_metrics metrics; diff --git a/eigrpd/eigrp_topology.c b/eigrpd/eigrp_topology.c index 8390bfc66..f1bc83af6 100644 --- a/eigrpd/eigrp_topology.c +++ b/eigrpd/eigrp_topology.c @@ -54,8 +54,8 @@ static int eigrp_prefix_entry_cmp(struct eigrp_prefix_entry *, struct eigrp_prefix_entry *); static void eigrp_prefix_entry_del(struct eigrp_prefix_entry *); -static int eigrp_neighbor_entry_cmp(struct eigrp_neighbor_entry *, - struct eigrp_neighbor_entry *); +static int eigrp_nexthop_entry_cmp(struct eigrp_nexthop_entry *, + struct eigrp_nexthop_entry *); /* * Returns linkedlist used as topology table @@ -116,7 +116,7 @@ struct eigrp_prefix_entry *eigrp_prefix_entry_new() sizeof(struct eigrp_prefix_entry)); new->entries = list_new(); new->rij = list_new(); - new->entries->cmp = (int (*)(void *, void *))eigrp_neighbor_entry_cmp; + new->entries->cmp = (int (*)(void *, void *))eigrp_nexthop_entry_cmp; new->distance = new->fdistance = new->rdistance = EIGRP_MAX_METRIC; new->destination = NULL; @@ -126,8 +126,8 @@ struct eigrp_prefix_entry *eigrp_prefix_entry_new() /* * Topology entry comparison */ -static int eigrp_neighbor_entry_cmp(struct eigrp_neighbor_entry *entry1, - struct eigrp_neighbor_entry *entry2) +static int eigrp_nexthop_entry_cmp(struct eigrp_nexthop_entry *entry1, + struct eigrp_nexthop_entry *entry2) { if (entry1->distance < entry2->distance) return -1; @@ -141,12 +141,12 @@ static int eigrp_neighbor_entry_cmp(struct eigrp_neighbor_entry *entry1, * Returns new topology entry */ -struct eigrp_neighbor_entry *eigrp_neighbor_entry_new() +struct eigrp_nexthop_entry *eigrp_nexthop_entry_new() { - struct eigrp_neighbor_entry *new; + struct eigrp_nexthop_entry *new; - new = XCALLOC(MTYPE_EIGRP_NEIGHBOR_ENTRY, - sizeof(struct eigrp_neighbor_entry)); + new = XCALLOC(MTYPE_EIGRP_NEXTHOP_ENTRY, + sizeof(struct eigrp_nexthop_entry)); new->reported_distance = EIGRP_MAX_METRIC; new->distance = EIGRP_MAX_METRIC; @@ -185,8 +185,8 @@ void eigrp_prefix_entry_add(struct list *topology, /* * Adding topology entry to topology node */ -void eigrp_neighbor_entry_add(struct eigrp_prefix_entry *node, - struct eigrp_neighbor_entry *entry) +void eigrp_nexthop_entry_add(struct eigrp_prefix_entry *node, + struct eigrp_nexthop_entry *entry) { struct list *l = list_new(); @@ -229,13 +229,13 @@ void eigrp_prefix_entry_delete(struct list *topology, /* * Deleting topology entry from topology node */ -void eigrp_neighbor_entry_delete(struct eigrp_prefix_entry *node, - struct eigrp_neighbor_entry *entry) +void eigrp_nexthop_entry_delete(struct eigrp_prefix_entry *node, + struct eigrp_nexthop_entry *entry) { if (listnode_lookup(node->entries, entry) != NULL) { listnode_delete(node->entries, entry); eigrp_zebra_route_delete(node->destination); - XFREE(MTYPE_EIGRP_NEIGHBOR_ENTRY, entry); + XFREE(MTYPE_EIGRP_NEXTHOP_ENTRY, entry); } } @@ -283,11 +283,11 @@ eigrp_topology_table_lookup_ipv4(struct list *topology_table, struct list *eigrp_topology_get_successor(struct eigrp_prefix_entry *table_node) { struct list *successors = list_new(); - struct eigrp_neighbor_entry *data; + struct eigrp_nexthop_entry *data; struct listnode *node1, *node2; for (ALL_LIST_ELEMENTS(table_node->entries, node1, node2, data)) { - if (data->flags & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG) { + if (data->flags & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG) { listnode_add(successors, data); } } @@ -321,10 +321,10 @@ eigrp_topology_get_successor_max(struct eigrp_prefix_entry *table_node, return successors; } -struct eigrp_neighbor_entry * +struct eigrp_nexthop_entry * eigrp_prefix_entry_lookup(struct list *entries, struct eigrp_neighbor *nbr) { - struct eigrp_neighbor_entry *data; + struct eigrp_nexthop_entry *data; struct listnode *node, *nnode; for (ALL_LIST_ELEMENTS(entries, node, nnode, data)) { if (data->adv_router == nbr) { @@ -341,7 +341,7 @@ struct list *eigrp_neighbor_prefixes_lookup(struct eigrp *eigrp, { struct listnode *node1, *node11, *node2, *node22; struct eigrp_prefix_entry *prefix; - struct eigrp_neighbor_entry *entry; + struct eigrp_nexthop_entry *entry; /* create new empty list for prefixes storage */ struct list *prefixes = list_new(); @@ -365,7 +365,7 @@ enum metric_change eigrp_topology_update_distance(struct eigrp_fsm_action_messag { struct eigrp *eigrp = msg->eigrp; struct eigrp_prefix_entry *prefix = msg->prefix; - struct eigrp_neighbor_entry *entry = msg->entry; + struct eigrp_nexthop_entry *entry = msg->entry; enum metric_change change = METRIC_SAME; u_int32_t new_reported_distance; @@ -439,7 +439,7 @@ void eigrp_topology_update_all_node_flags(struct eigrp *eigrp) void eigrp_topology_update_node_flags(struct eigrp_prefix_entry *dest) { struct listnode *node; - struct eigrp_neighbor_entry *entry; + struct eigrp_nexthop_entry *entry; struct eigrp *eigrp = eigrp_lookup(); for (ALL_LIST_ELEMENTS_RO(dest->entries, node, entry)) { @@ -447,16 +447,16 @@ void eigrp_topology_update_node_flags(struct eigrp_prefix_entry *dest) <= (uint64_t)dest->distance * (uint64_t)eigrp->variance) && entry->distance != EIGRP_MAX_METRIC) // is successor { - entry->flags |= EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG; - entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG; + entry->flags |= EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG; + entry->flags &= ~EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG; } else if (entry->reported_distance < dest->fdistance) // is feasible successor { - entry->flags |= EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG; - entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG; + entry->flags |= EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG; + entry->flags &= ~EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG; } else { - entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG; - entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG; + entry->flags &= ~EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG; + entry->flags &= ~EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG; } } } @@ -467,19 +467,19 @@ void eigrp_update_routing_table(struct eigrp_prefix_entry *prefix) struct list *successors = eigrp_topology_get_successor_max(prefix, eigrp->max_paths); struct listnode *node; - struct eigrp_neighbor_entry *entry; + struct eigrp_nexthop_entry *entry; if (successors) { eigrp_zebra_route_add(prefix->destination, successors); for (ALL_LIST_ELEMENTS_RO(successors, node, entry)) - entry->flags |= EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG; + entry->flags |= EIGRP_NEXTHOP_ENTRY_INTABLE_FLAG; list_delete(successors); } else { eigrp_zebra_route_delete(prefix->destination); for (ALL_LIST_ELEMENTS_RO(prefix->entries, node, entry)) - entry->flags &= ~EIGRP_NEIGHBOR_ENTRY_INTABLE_FLAG; + entry->flags &= ~EIGRP_NEXTHOP_ENTRY_INTABLE_FLAG; } } @@ -488,7 +488,7 @@ void eigrp_topology_neighbor_down(struct eigrp *eigrp, { struct listnode *node1, *node11, *node2, *node22; struct eigrp_prefix_entry *prefix; - struct eigrp_neighbor_entry *entry; + struct eigrp_nexthop_entry *entry; for (ALL_LIST_ELEMENTS(eigrp->topology_table, node1, node11, prefix)) { for (ALL_LIST_ELEMENTS(prefix->entries, node2, node22, entry)) { @@ -517,10 +517,10 @@ void eigrp_update_topology_table_prefix(struct list *table, { struct listnode *node1, *node2; - struct eigrp_neighbor_entry *entry; + struct eigrp_nexthop_entry *entry; for (ALL_LIST_ELEMENTS(prefix->entries, node1, node2, entry)) { if (entry->distance == EIGRP_MAX_METRIC) { - eigrp_neighbor_entry_delete(prefix, entry); + eigrp_nexthop_entry_delete(prefix, entry); } } if (prefix->distance == EIGRP_MAX_METRIC diff --git a/eigrpd/eigrp_topology.h b/eigrpd/eigrp_topology.h index 8bff08b75..ef5b32d5b 100644 --- a/eigrpd/eigrp_topology.h +++ b/eigrpd/eigrp_topology.h @@ -36,16 +36,16 @@ extern struct list *eigrp_topology_new(void); extern void eigrp_topology_init(struct list *); extern struct eigrp_prefix_entry *eigrp_prefix_entry_new(void); -extern struct eigrp_neighbor_entry *eigrp_neighbor_entry_new(void); +extern struct eigrp_nexthop_entry *eigrp_nexthop_entry_new(void); extern void eigrp_topology_free(struct list *); extern void eigrp_topology_cleanup(struct list *); extern void eigrp_prefix_entry_add(struct list *, struct eigrp_prefix_entry *); -extern void eigrp_neighbor_entry_add(struct eigrp_prefix_entry *, - struct eigrp_neighbor_entry *); +extern void eigrp_nexthop_entry_add(struct eigrp_prefix_entry *, + struct eigrp_nexthop_entry *); extern void eigrp_prefix_entry_delete(struct list *, struct eigrp_prefix_entry *); -extern void eigrp_neighbor_entry_delete(struct eigrp_prefix_entry *, - struct eigrp_neighbor_entry *); +extern void eigrp_nexthop_entry_delete(struct eigrp_prefix_entry *, + struct eigrp_nexthop_entry *); extern void eigrp_topology_delete_all(struct list *); extern unsigned int eigrp_topology_table_isempty(struct list *); extern struct eigrp_prefix_entry * @@ -54,7 +54,7 @@ extern struct list *eigrp_topology_get_successor(struct eigrp_prefix_entry *); extern struct list * eigrp_topology_get_successor_max(struct eigrp_prefix_entry *pe, unsigned int maxpaths); -extern struct eigrp_neighbor_entry * +extern struct eigrp_nexthop_entry * eigrp_prefix_entry_lookup(struct list *, struct eigrp_neighbor *); extern struct list *eigrp_neighbor_prefixes_lookup(struct eigrp *, struct eigrp_neighbor *); diff --git a/eigrpd/eigrp_update.c b/eigrpd/eigrp_update.c index 430068496..baa1ac553 100644 --- a/eigrpd/eigrp_update.c +++ b/eigrpd/eigrp_update.c @@ -63,6 +63,32 @@ #include "eigrpd/eigrp_network.h" #include "eigrpd/eigrp_memory.h" +bool eigrp_update_prefix_apply(struct eigrp *eigrp, + struct eigrp_interface *ei, + int in, struct prefix *prefix) +{ + struct access_list *alist; + struct prefix_list *plist; + + alist = eigrp->list[in]; + if (alist && access_list_apply(alist, prefix) == FILTER_DENY) + return true; + + plist = eigrp->prefix[in]; + if (plist && prefix_list_apply(plist, prefix) == PREFIX_DENY) + return true; + + alist = ei->list[in]; + if (alist && access_list_apply(alist, prefix) == FILTER_DENY) + return true; + + plist = ei->prefix[in]; + if (plist && prefix_list_apply(plist, prefix) == PREFIX_DENY) + return true; + + return false; +} + /** * @fn remove_received_prefix_gr * @@ -125,7 +151,7 @@ static void eigrp_update_receive_GR_ask(struct eigrp *eigrp, /* set delay to MAX */ fsm_msg.metrics.delay = EIGRP_MAX_METRIC; - struct eigrp_neighbor_entry *entry = + struct eigrp_nexthop_entry *entry = eigrp_prefix_entry_lookup(prefix->entries, nbr); fsm_msg.packet_type = EIGRP_OPC_UPDATE; @@ -150,15 +176,12 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph, struct eigrp_neighbor *nbr; struct TLV_IPv4_Internal_type *tlv; struct eigrp_prefix_entry *pe; - struct eigrp_neighbor_entry *ne; + struct eigrp_nexthop_entry *ne; u_int32_t flags; u_int16_t type; u_int16_t length; u_char same; - struct access_list *alist; - struct prefix_list *plist; struct prefix dest_addr; - struct eigrp *e; u_char graceful_restart; u_char graceful_restart_final; struct list *nbr_prefixes = NULL; @@ -296,7 +319,7 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph, dest); struct eigrp_fsm_action_message msg; - struct eigrp_neighbor_entry *entry = + struct eigrp_nexthop_entry *entry = eigrp_prefix_entry_lookup(dest->entries, nbr); @@ -319,7 +342,7 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph, pe->state = EIGRP_FSM_STATE_PASSIVE; pe->nt = EIGRP_TOPOLOGY_TYPE_REMOTE; - ne = eigrp_neighbor_entry_new(); + ne = eigrp_nexthop_entry_new(); ne->ei = ei; ne->adv_router = nbr; ne->reported_metric = tlv->metric; @@ -328,67 +351,10 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph, /* * Filtering */ - e = eigrp_lookup(); - /* - * Check if there is any access-list on - * interface (IN direction) - * and set distance to max - */ - alist = ei->list[EIGRP_FILTER_IN]; - - /* Check if access-list fits */ - if (alist - && access_list_apply(alist, - &dest_addr) - == FILTER_DENY) { - /* If yes, set reported metric to Max */ - ne->reported_metric.delay = - EIGRP_MAX_METRIC; - } else { - ne->distance = - eigrp_calculate_total_metrics( - eigrp, ne); - } - - plist = e->prefix[EIGRP_FILTER_IN]; - - /* Check if prefix-list fits */ - if (plist - && prefix_list_apply(plist, - &dest_addr) - == PREFIX_DENY) { - /* If yes, set reported metric to Max */ - ne->reported_metric.delay = - EIGRP_MAX_METRIC; - } - - /*Get access-list from current interface */ - alist = ei->list[EIGRP_FILTER_IN]; - - /* Check if access-list fits */ - if (alist - && access_list_apply(alist, - &dest_addr) - == FILTER_DENY) { - /* If yes, set reported metric to Max */ - ne->reported_metric.delay = - EIGRP_MAX_METRIC; - } - - plist = ei->prefix[EIGRP_FILTER_IN]; - - /* Check if prefix-list fits */ - if (plist - && prefix_list_apply(plist, - &dest_addr) - == PREFIX_DENY) { - /* If yes, set reported metric to Max */ - ne->reported_metric.delay = - EIGRP_MAX_METRIC; - } - /* - * End of filtering - */ + if (eigrp_update_prefix_apply(eigrp, ei, + EIGRP_FILTER_IN, + &dest_addr)) + ne->reported_metric.delay = EIGRP_MAX_METRIC; ne->distance = eigrp_calculate_total_metrics( eigrp, ne); @@ -396,11 +362,11 @@ void eigrp_update_receive(struct eigrp *eigrp, struct ip *iph, pe->fdistance = pe->distance = pe->rdistance = ne->distance; ne->prefix = pe; - ne->flags = EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG; + ne->flags = EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG; eigrp_prefix_entry_add(eigrp->topology_table, pe); - eigrp_neighbor_entry_add(pe, ne); + eigrp_nexthop_entry_add(pe, ne); pe->distance = pe->fdistance = pe->rdistance = ne->distance; pe->reported_metric = ne->total_metric; @@ -562,86 +528,64 @@ void eigrp_update_send_EOT(struct eigrp_neighbor *nbr) { struct eigrp_packet *ep; u_int16_t length = EIGRP_HEADER_LEN; - struct eigrp_neighbor_entry *te; + struct eigrp_nexthop_entry *te; struct eigrp_prefix_entry *pe; struct listnode *node, *node2, *nnode, *nnode2; - struct access_list *alist; - struct prefix_list *plist; - struct access_list *alist_i; - struct prefix_list *plist_i; - struct eigrp *e; + struct eigrp_interface *ei = nbr->ei; + struct eigrp *eigrp = ei->eigrp; struct prefix *dest_addr; - u_int32_t seq_no = nbr->ei->eigrp->sequence_number; + u_int32_t seq_no = eigrp->sequence_number; - ep = eigrp_packet_new(nbr->ei->ifp->mtu, nbr); + ep = eigrp_packet_new(ei->ifp->mtu, nbr); /* Prepare EIGRP EOT UPDATE header */ - eigrp_packet_header_init(EIGRP_OPC_UPDATE, nbr->ei->eigrp, + eigrp_packet_header_init(EIGRP_OPC_UPDATE, eigrp, ep->s, EIGRP_EOT_FLAG, seq_no, nbr->recv_sequence_number); // encode Authentication TLV, if needed - if((IF_DEF_PARAMS (nbr->ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) && - (IF_DEF_PARAMS (nbr->ei->ifp)->auth_keychain != NULL)) { - length += eigrp_add_authTLV_MD5_to_stream(ep->s,nbr->ei); + if((IF_DEF_PARAMS (ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) && + (IF_DEF_PARAMS (ei->ifp)->auth_keychain != NULL)) { + length += eigrp_add_authTLV_MD5_to_stream(ep->s,ei); } - for (ALL_LIST_ELEMENTS(nbr->ei->eigrp->topology_table, node, nnode, pe)) { + for (ALL_LIST_ELEMENTS(eigrp->topology_table, node, nnode, pe)) { for (ALL_LIST_ELEMENTS(pe->entries, node2, nnode2, te)) { - if (eigrp_nbr_split_horizon_check(te, nbr->ei)) + if (eigrp_nbr_split_horizon_check(te, ei)) continue; - if ((length + 0x001D) > (u_int16_t)nbr->ei->ifp->mtu) { + if ((length + 0x001D) > (u_int16_t)ei->ifp->mtu) { eigrp_update_place_on_nbr_queue (nbr, ep, seq_no, length); seq_no++; length = EIGRP_HEADER_LEN; - ep = eigrp_packet_new(nbr->ei->ifp->mtu, nbr); - eigrp_packet_header_init(EIGRP_OPC_UPDATE, nbr->ei->eigrp, + ep = eigrp_packet_new(ei->ifp->mtu, nbr); + eigrp_packet_header_init(EIGRP_OPC_UPDATE, eigrp, ep->s, EIGRP_EOT_FLAG, seq_no, nbr->recv_sequence_number); - if((IF_DEF_PARAMS (nbr->ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) && - (IF_DEF_PARAMS (nbr->ei->ifp)->auth_keychain != NULL)) + if((IF_DEF_PARAMS (ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) && + (IF_DEF_PARAMS (ei->ifp)->auth_keychain != NULL)) { - length += eigrp_add_authTLV_MD5_to_stream(ep->s,nbr->ei); + length += eigrp_add_authTLV_MD5_to_stream(ep->s,ei); } } /* Get destination address from prefix */ dest_addr = pe->destination; - /* - * Filtering - */ - //TODO: Work in progress - /* get list from eigrp process */ - e = eigrp_lookup(); - /* Get access-lists and prefix-lists from process and interface */ - alist = e->list[EIGRP_FILTER_OUT]; - plist = e->prefix[EIGRP_FILTER_OUT]; - alist_i = nbr->ei->list[EIGRP_FILTER_OUT]; - plist_i = nbr->ei->prefix[EIGRP_FILTER_OUT]; - /* Check if any list fits */ - if ((alist - && access_list_apply (alist, - dest_addr) == FILTER_DENY)|| - (plist && prefix_list_apply (plist, - dest_addr) == PREFIX_DENY)|| - (alist_i && access_list_apply (alist_i, - dest_addr) == FILTER_DENY)|| - (plist_i && prefix_list_apply (plist_i, - dest_addr) == PREFIX_DENY)) { - //pe->reported_metric.delay = EIGRP_MAX_METRIC; + if (eigrp_update_prefix_apply(eigrp, ei, + EIGRP_FILTER_OUT, + dest_addr)) continue; - } else { + else { length += eigrp_add_internalTLV_to_stream(ep->s, pe); } } } eigrp_update_place_on_nbr_queue (nbr, ep, seq_no, length); - nbr->ei->eigrp->sequence_number = seq_no++; + eigrp->sequence_number = seq_no++; } void eigrp_update_send(struct eigrp_interface *ei) @@ -650,13 +594,9 @@ void eigrp_update_send(struct eigrp_interface *ei) struct listnode *node, *nnode; struct eigrp_prefix_entry *pe; u_char has_tlv; - struct access_list *alist; - struct prefix_list *plist; - struct access_list *alist_i; - struct prefix_list *plist_i; - struct eigrp *e; + struct eigrp *eigrp = ei->eigrp; struct prefix *dest_addr; - u_int32_t seq_no = ei->eigrp->sequence_number; + u_int32_t seq_no = eigrp->sequence_number; if (ei->nbrs->count == 0) return; @@ -666,7 +606,7 @@ void eigrp_update_send(struct eigrp_interface *ei) ep = eigrp_packet_new(ei->ifp->mtu, NULL); /* Prepare EIGRP INIT UPDATE header */ - eigrp_packet_header_init(EIGRP_OPC_UPDATE, ei->eigrp, + eigrp_packet_header_init(EIGRP_OPC_UPDATE, eigrp, ep->s, 0, seq_no, 0); // encode Authentication TLV, if needed @@ -678,7 +618,7 @@ void eigrp_update_send(struct eigrp_interface *ei) has_tlv = 0; for (ALL_LIST_ELEMENTS(ei->eigrp->topology_changes_internalIPV4, node, nnode, pe)) { - struct eigrp_neighbor_entry *ne; + struct eigrp_nexthop_entry *ne; if (!(pe->req_action & EIGRP_FSM_NEED_UPDATE)) continue; @@ -704,7 +644,7 @@ void eigrp_update_send(struct eigrp_interface *ei) length = EIGRP_HEADER_LEN; ep = eigrp_packet_new(ei->ifp->mtu, NULL); - eigrp_packet_header_init(EIGRP_OPC_UPDATE, ei->eigrp, + eigrp_packet_header_init(EIGRP_OPC_UPDATE, eigrp, ep->s, 0, seq_no, 0); if ((IF_DEF_PARAMS(ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) && (IF_DEF_PARAMS(ei->ifp)->auth_keychain != NULL)) { @@ -715,34 +655,9 @@ void eigrp_update_send(struct eigrp_interface *ei) /* Get destination address from prefix */ dest_addr = pe->destination; - /* - * Filtering - */ - e = eigrp_lookup(); - /* Get access-lists and prefix-lists from process and - * interface */ - alist = e->list[EIGRP_FILTER_OUT]; - plist = e->prefix[EIGRP_FILTER_OUT]; - alist_i = ei->list[EIGRP_FILTER_OUT]; - plist_i = ei->prefix[EIGRP_FILTER_OUT]; - - /* Check if any list fits */ - if ((alist - && access_list_apply(alist, - dest_addr) - == FILTER_DENY) - || (plist - && prefix_list_apply(plist, - dest_addr) - == PREFIX_DENY) - || (alist_i - && access_list_apply(alist_i, - dest_addr) - == FILTER_DENY) - || (plist_i - && prefix_list_apply(plist_i, - dest_addr) - == PREFIX_DENY)) { + if (eigrp_update_prefix_apply(eigrp, ei, + EIGRP_FILTER_OUT, + dest_addr)) { // pe->reported_metric.delay = EIGRP_MAX_METRIC; continue; } else { @@ -769,7 +684,7 @@ void eigrp_update_send(struct eigrp_interface *ei) ep->dst.s_addr = htonl(EIGRP_MULTICAST_ADDRESS); /*This ack number we await from neighbor*/ - ep->sequence_number = ei->eigrp->sequence_number; + ep->sequence_number = eigrp->sequence_number; if (IS_DEBUG_EIGRP_PACKET(0, RECV)) zlog_debug("Enqueuing Update length[%u] Seq [%u]", length, @@ -824,9 +739,8 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr) struct listnode *node, *nnode; struct eigrp_prefix_entry *pe; struct prefix *dest_addr; - struct eigrp *e; - struct access_list *alist, *alist_i; - struct prefix_list *plist, *plist_i; + struct eigrp_interface *ei = nbr->ei; + struct eigrp *eigrp = ei->eigrp; struct list *prefixes; u_int32_t flags; unsigned int send_prefixes; @@ -868,47 +782,28 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr) } } - ep = eigrp_packet_new(nbr->ei->ifp->mtu, nbr); + ep = eigrp_packet_new(ei->ifp->mtu, nbr); /* Prepare EIGRP Graceful restart UPDATE header */ - eigrp_packet_header_init(EIGRP_OPC_UPDATE, nbr->ei->eigrp, ep->s, flags, - nbr->ei->eigrp->sequence_number, + eigrp_packet_header_init(EIGRP_OPC_UPDATE, eigrp, ep->s, flags, + eigrp->sequence_number, nbr->recv_sequence_number); // encode Authentication TLV, if needed - if ((IF_DEF_PARAMS(nbr->ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) - && (IF_DEF_PARAMS(nbr->ei->ifp)->auth_keychain != NULL)) { - length += eigrp_add_authTLV_MD5_to_stream(ep->s, nbr->ei); + if ((IF_DEF_PARAMS(ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) + && (IF_DEF_PARAMS(ei->ifp)->auth_keychain != NULL)) { + length += eigrp_add_authTLV_MD5_to_stream(ep->s, ei); } - for (ALL_LIST_ELEMENTS(nbr->ei->eigrp->topology_table, node, nnode, - pe)) { + for (ALL_LIST_ELEMENTS(eigrp->topology_table, node, nnode, pe)) { /* * Filtering */ dest_addr = pe->destination; - /* get list from eigrp process */ - e = eigrp_lookup(); - /* Get access-lists and prefix-lists from process and interface - */ - alist = e->list[EIGRP_FILTER_OUT]; - plist = e->prefix[EIGRP_FILTER_OUT]; - alist_i = nbr->ei->list[EIGRP_FILTER_OUT]; - plist_i = nbr->ei->prefix[EIGRP_FILTER_OUT]; - - /* Check if any list fits */ - if ((alist - && access_list_apply(alist, dest_addr) - == FILTER_DENY) - || (plist - && prefix_list_apply(plist, dest_addr) - == PREFIX_DENY) - || (alist_i - && access_list_apply(alist_i, dest_addr) - == FILTER_DENY) - || (plist_i - && prefix_list_apply(plist_i, dest_addr) - == PREFIX_DENY)) { + + if (eigrp_update_prefix_apply(eigrp, ei, + EIGRP_FILTER_OUT, + dest_addr)) { /* do not send filtered route */ zlog_info("Filtered prefix %s won't be sent out.", inet_ntoa(dest_addr->u.prefix4)); @@ -918,24 +813,13 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr) send_prefixes++; } - alist = e->list[EIGRP_FILTER_IN]; - plist = e->prefix[EIGRP_FILTER_IN]; - alist_i = nbr->ei->list[EIGRP_FILTER_IN]; - plist_i = nbr->ei->prefix[EIGRP_FILTER_IN]; - - /* Check if any list fits */ - if ((alist - && access_list_apply(alist, dest_addr) - == FILTER_DENY) - || (plist - && prefix_list_apply(plist, dest_addr) - == PREFIX_DENY) - || (alist_i - && access_list_apply(alist_i, dest_addr) - == FILTER_DENY) - || (plist_i - && prefix_list_apply(plist_i, dest_addr) - == PREFIX_DENY)) { + /* + * This makes no sense, Filter out then filter in??? + * Look into this more - DBS + */ + if (eigrp_update_prefix_apply(eigrp, ei, + EIGRP_FILTER_IN, + dest_addr)) { /* do not send filtered route */ zlog_info("Filtered prefix %s will be removed.", inet_ntoa(dest_addr->u.prefix4)); @@ -943,11 +827,11 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr) /* prepare message for FSM */ struct eigrp_fsm_action_message fsm_msg; - struct eigrp_neighbor_entry *entry = + struct eigrp_nexthop_entry *entry = eigrp_prefix_entry_lookup(pe->entries, nbr); fsm_msg.packet_type = EIGRP_OPC_UPDATE; - fsm_msg.eigrp = e; + fsm_msg.eigrp = eigrp; fsm_msg.data_type = EIGRP_INT; fsm_msg.adv_router = nbr; fsm_msg.metrics = pe->reported_metric; @@ -959,9 +843,6 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr) /* send message to FSM */ eigrp_fsm_event(&fsm_msg); } - /* - * End of filtering - */ /* NULL the pointer */ dest_addr = NULL; @@ -975,19 +856,19 @@ static void eigrp_update_send_GR_part(struct eigrp_neighbor *nbr) } /* compute Auth digest */ - if ((IF_DEF_PARAMS(nbr->ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) - && (IF_DEF_PARAMS(nbr->ei->ifp)->auth_keychain != NULL)) { - eigrp_make_md5_digest(nbr->ei, ep->s, EIGRP_AUTH_UPDATE_FLAG); + if ((IF_DEF_PARAMS(ei->ifp)->auth_type == EIGRP_AUTH_TYPE_MD5) + && (IF_DEF_PARAMS(ei->ifp)->auth_keychain != NULL)) { + eigrp_make_md5_digest(ei, ep->s, EIGRP_AUTH_UPDATE_FLAG); } /* EIGRP Checksum */ - eigrp_packet_checksum(nbr->ei, ep->s, length); + eigrp_packet_checksum(ei, ep->s, length); ep->length = length; ep->dst.s_addr = nbr->src.s_addr; /*This ack number we await from neighbor*/ - ep->sequence_number = nbr->ei->eigrp->sequence_number; + ep->sequence_number = eigrp->sequence_number; if (IS_DEBUG_EIGRP_PACKET(0, RECV)) zlog_debug("Enqueuing Update Init Len [%u] Seq [%u] Dest [%s]", diff --git a/eigrpd/eigrp_vty.c b/eigrpd/eigrp_vty.c index d4d3bb369..01407a746 100644 --- a/eigrpd/eigrp_vty.c +++ b/eigrpd/eigrp_vty.c @@ -464,7 +464,7 @@ DEFUN (show_ip_eigrp_topology, struct eigrp *eigrp; struct listnode *node, *node2; struct eigrp_prefix_entry *tn; - struct eigrp_neighbor_entry *te; + struct eigrp_nexthop_entry *te; int first; eigrp = eigrp_lookup(); @@ -480,12 +480,12 @@ DEFUN (show_ip_eigrp_topology, for (ALL_LIST_ELEMENTS_RO(tn->entries, node2, te)) { if (argc == 5 || (((te->flags - & EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG) - == EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG) + & EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG) + == EIGRP_NEXTHOP_ENTRY_SUCCESSOR_FLAG) || ((te->flags - & EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG) - == EIGRP_NEIGHBOR_ENTRY_FSUCCESSOR_FLAG))) { - show_ip_eigrp_neighbor_entry(vty, eigrp, te, + & EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG) + == EIGRP_NEXTHOP_ENTRY_FSUCCESSOR_FLAG))) { + show_ip_eigrp_nexthop_entry(vty, eigrp, te, &first); first = 0; } diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c index 47871dfd3..e61b3d748 100644 --- a/eigrpd/eigrp_zebra.c +++ b/eigrpd/eigrp_zebra.c @@ -365,7 +365,7 @@ void eigrp_zebra_route_add(struct prefix *p, struct list *successors) { struct zapi_route api; struct zapi_nexthop *api_nh; - struct eigrp_neighbor_entry *te; + struct eigrp_nexthop_entry *te; struct listnode *node; int count = 0; |