-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ip6: answer to router sollicit message
Upon reception of a router sollicit message, trigger the existing timer to send immediately a router advertismement packet. Add relevant test: as the same mac address is defined for 2 interfaces in the 2 namespaces, the same link local ip address will be generated and used by linux. Update github workflow and doc to reflect the addition of 'ndisc6' as a test tool. Signed-off-by: Christophe Fontaine <[email protected]>
- Loading branch information
1 parent
65aa832
commit 2e45b6c
Showing
9 changed files
with
331 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright (c) 2025 Christophe Fontaine | ||
|
||
#include <gr_control_output.h> | ||
#include <gr_graph.h> | ||
#include <gr_icmp6.h> | ||
#include <gr_ip6_control.h> | ||
#include <gr_ip6_datapath.h> | ||
#include <gr_log.h> | ||
#include <gr_mbuf.h> | ||
#include <gr_trace.h> | ||
|
||
#include <rte_byteorder.h> | ||
#include <rte_ether.h> | ||
#include <rte_graph_worker.h> | ||
#include <rte_ip6.h> | ||
|
||
enum { | ||
CONTROL, | ||
INVAL, | ||
EDGE_COUNT, | ||
}; | ||
|
||
static uint16_t ndp_rs_input_process( | ||
struct rte_graph *graph, | ||
struct rte_node *node, | ||
void **objs, | ||
uint16_t nb_objs | ||
) { | ||
struct control_output_mbuf_data *co; | ||
struct ip6_local_mbuf_data *d; | ||
struct rte_mbuf *mbuf; | ||
struct icmp6 *icmp6; | ||
rte_edge_t next; | ||
|
||
#define ASSERT_NDP(condition) \ | ||
do { \ | ||
if (!(condition)) { \ | ||
next = INVAL; \ | ||
goto next; \ | ||
} \ | ||
} while (0) | ||
|
||
for (uint16_t i = 0; i < nb_objs; i++) { | ||
mbuf = objs[i]; | ||
|
||
d = ip6_local_mbuf_data(mbuf); | ||
icmp6 = rte_pktmbuf_mtod(mbuf, struct icmp6 *); | ||
|
||
// Validation of Router Solicitations | ||
// https://www.rfc-editor.org/rfc/rfc4861#section-6.1.1 | ||
// | ||
// - The IP Hop Limit field has a value of 255, i.e., the packet | ||
// could not possibly have been forwarded by a router. | ||
ASSERT_NDP(d->hop_limit == 255); | ||
// - ICMP Checksum is valid. (already checked in icmp6_input) | ||
// | ||
// - ICMP Code is 0. | ||
ASSERT_NDP(icmp6->code == 0); | ||
// - ICMP length (derived from the IP length) is 8 or more octets. | ||
ASSERT_NDP(d->len >= 8); | ||
|
||
next = CONTROL; | ||
co = control_output_mbuf_data(mbuf); | ||
co->callback = ndp_router_sollicit_input_cb; | ||
next: | ||
if (gr_mbuf_is_traced(mbuf)) | ||
gr_mbuf_trace_add(mbuf, node, 0); | ||
rte_node_enqueue_x1(graph, node, next, mbuf); | ||
} | ||
|
||
return nb_objs; | ||
} | ||
|
||
static struct rte_node_register node = { | ||
.name = "ndp_rs_input", | ||
.process = ndp_rs_input_process, | ||
.nb_edges = EDGE_COUNT, | ||
.next_nodes = { | ||
[CONTROL] = "control_output", | ||
[INVAL] = "ndp_rs_input_inval", | ||
}, | ||
}; | ||
|
||
static struct gr_node_info info = { | ||
.node = &node, | ||
.trace_format = (gr_trace_format_cb_t)trace_icmp6_format, | ||
}; | ||
|
||
GR_NODE_REGISTER(info); | ||
|
||
GR_DROP_REGISTER(ndp_rs_input_inval); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright (c) 2025 Christophe Fontaine | ||
|
||
. $(dirname $0)/_init.sh | ||
|
||
p1=${run_id}1 | ||
|
||
grcli add interface port $p1 devargs net_tap0,iface=$p1 mac d2:f0:0c:ba:a4:11 | ||
grcli add ip6 address fd00:ba4:1::1/64 iface $p1 | ||
|
||
for n in 1; do | ||
p=$run_id$n | ||
ip netns add $p | ||
echo ip netns del $p >> $tmp/cleanup | ||
ip link set $p netns $p | ||
ip -n $p link set $p address d2:ad:ca:ca:a4:1$n | ||
ip -n $p link set $p up | ||
ip -n $p addr add fd00:ba4:$n::2/64 dev $p | ||
ip -n $p addr show | ||
done | ||
|
||
sleep 3 # wait for DAD | ||
|
||
ip netns exec $p1 rdisc6 $p1 |