From e29ae5f034f39eaa3c2117e70156cf81d5dc2cef Mon Sep 17 00:00:00 2001 From: Christian Giese Date: Wed, 20 Mar 2024 21:17:46 +0000 Subject: [PATCH] fix OSPFv2/3 running on same interface --- code/bngblaster/src/bbl_network.c | 4 ++-- code/bngblaster/src/bbl_network.h | 3 ++- code/bngblaster/src/ospf/ospf.c | 4 ++-- code/bngblaster/src/ospf/ospf_hello.c | 4 ++-- code/bngblaster/src/ospf/ospf_interface.c | 3 ++- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/code/bngblaster/src/bbl_network.c b/code/bngblaster/src/bbl_network.c index d2251c47..6779dc9f 100644 --- a/code/bngblaster/src/bbl_network.c +++ b/code/bngblaster/src/bbl_network.c @@ -466,7 +466,7 @@ bbl_network_rx_handler(bbl_network_interface_s *interface, } bbl_tcp_ipv4_rx(interface, eth, ipv4); return; - } else if(ipv4->protocol == PROTOCOL_IPV4_OSPF && interface->ospf_interface) { + } else if(ipv4->protocol == PROTOCOL_IPV4_OSPF && interface->ospfv2_interface) { ospf_handler_rx_ipv4(interface, eth, ipv4); return; } @@ -491,7 +491,7 @@ bbl_network_rx_handler(bbl_network_interface_s *interface, } bbl_tcp_ipv6_rx(interface, eth, ipv6); return; - } else if(ipv6->protocol == IPV6_NEXT_HEADER_OSPF && interface->ospf_interface) { + } else if(ipv6->protocol == IPV6_NEXT_HEADER_OSPF && interface->ospfv3_interface) { ospf_handler_rx_ipv6(interface, eth, ipv6); return; } diff --git a/code/bngblaster/src/bbl_network.h b/code/bngblaster/src/bbl_network.h index 767940c8..19a3bda7 100644 --- a/code/bngblaster/src/bbl_network.h +++ b/code/bngblaster/src/bbl_network.h @@ -66,7 +66,8 @@ typedef struct bbl_network_interface_ isis_adjacency_p2p_s *isis_adjacency_p2p; isis_adjacency_s *isis_adjacency[ISIS_LEVELS]; ldp_adjacency_s *ldp_adjacency; - ospf_interface_s *ospf_interface; + ospf_interface_s *ospfv2_interface; + ospf_interface_s *ospfv3_interface; struct { uint64_t packets_tx; diff --git a/code/bngblaster/src/ospf/ospf.c b/code/bngblaster/src/ospf/ospf.c index aff7f65e..67bb5f7c 100644 --- a/code/bngblaster/src/ospf/ospf.c +++ b/code/bngblaster/src/ospf/ospf.c @@ -87,7 +87,7 @@ ospf_handler_rx_ipv4(bbl_network_interface_s *interface, protocol_error_t result; ospf_pdu_s pdu = {0}; - ospf_interface_s *ospf_interface = interface->ospf_interface; + ospf_interface_s *ospf_interface = interface->ospfv2_interface; ospf_neighbor_s *ospf_neighbor = ospf_interface->neighbors; ospf_config_s *config = ospf_interface->instance->config; @@ -224,7 +224,7 @@ ospf_handler_rx_ipv6(bbl_network_interface_s *interface, protocol_error_t result; ospf_pdu_s pdu = {0}; - ospf_interface_s *ospf_interface = interface->ospf_interface; + ospf_interface_s *ospf_interface = interface->ospfv3_interface; ospf_neighbor_s *ospf_neighbor = ospf_interface->neighbors; bbl_ospf_s *ospf = ipv6->next; diff --git a/code/bngblaster/src/ospf/ospf_hello.c b/code/bngblaster/src/ospf/ospf_hello.c index 3141944f..a5a754b5 100644 --- a/code/bngblaster/src/ospf/ospf_hello.c +++ b/code/bngblaster/src/ospf/ospf_hello.c @@ -28,7 +28,7 @@ ospf_hello_v2_encode(bbl_network_interface_s *interface, bbl_ospf_s ospf = {0}; ospf_pdu_s pdu = {0}; - ospf_interface_s *ospf_interface = interface->ospf_interface; + ospf_interface_s *ospf_interface = interface->ospfv2_interface; ospf_neighbor_s *ospf_neighbor = ospf_interface->neighbors; ospf_instance_s *ospf_instance = ospf_interface->instance; ospf_config_s *config = ospf_instance->config; @@ -122,7 +122,7 @@ ospf_hello_v3_encode(bbl_network_interface_s *interface, ospf_pdu_s pdu = {0}; uint8_t mac[ETH_ADDR_LEN]; - ospf_interface_s *ospf_interface = interface->ospf_interface; + ospf_interface_s *ospf_interface = interface->ospfv3_interface; ospf_neighbor_s *ospf_neighbor = ospf_interface->neighbors; ospf_instance_s *ospf_instance = ospf_interface->instance; ospf_config_s *config = ospf_instance->config; diff --git a/code/bngblaster/src/ospf/ospf_interface.c b/code/bngblaster/src/ospf/ospf_interface.c index e306d98f..521a6080 100644 --- a/code/bngblaster/src/ospf/ospf_interface.c +++ b/code/bngblaster/src/ospf/ospf_interface.c @@ -250,18 +250,19 @@ ospf_interface_init(bbl_network_interface_s *interface, return false; } ospf_interface = calloc(1, sizeof(ospf_interface_s)); - interface->ospf_interface = ospf_interface; ospf_interface->interface = interface; ospf_interface->instance = ospf; ospf_interface->version = version; ospf_interface->type = interface_type; ospf_interface->id = interface_id++; if(version == OSPF_VERSION_2) { + interface->ospfv2_interface = ospf_interface; ospf_interface->metric = network_config->ospfv2_metric; ospf_interface->frag_buf = malloc(OSPF_PDU_LEN_MAX); ospf_interface->frag_id = 0; ospf_interface->frag_off = 0; } else { + interface->ospfv3_interface = ospf_interface; ospf_interface->metric = network_config->ospfv3_metric; }