Skip to content

Commit

Permalink
fixup! ip: send an icmp message when TTL is expired
Browse files Browse the repository at this point in the history
apply requested changes

Signed-off-by: Christophe Fontaine <cfontain@redhat.com>
  • Loading branch information
christophefontaine committed Jul 2, 2024
1 parent e04342b commit 2f64ace
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions modules/ip/datapath/ip_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ ip_input_process(struct rte_graph *graph, struct rte_node *node, void **objs, ui
next = FORWARD;
// Store the resolved next hop for ip_output to avoid a second route lookup.
ip_output_mbuf_data(mbuf)->nh = nh;
ip_output_mbuf_data(mbuf)->input_iface = iface;
next_packet:
rte_node_enqueue_x1(graph, node, next, mbuf);
}
Expand Down
22 changes: 12 additions & 10 deletions modules/ip/datapath/ip_ttl_exceeded.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ enum edges {
EDGE_COUNT,
};

static uint16_t
ip_ttl_exceeded(struct rte_graph *graph, struct rte_node *node, void **objs, uint16_t nb_objs) {
rte_edge_t next = ICMP_OUTPUT;
static uint16_t ip_ttl_exceeded_process(
struct rte_graph *graph,
struct rte_node *node,
void **objs,
uint16_t nb_objs
) {
uint16_t vrf_id;
struct rte_mbuf *mbuf;
struct rte_ipv4_hdr *ip;
struct ip_local_mbuf_data *ip_data;
struct rte_icmp_hdr *icmp;
struct rte_mbuf *mbuf;
const struct iface *input_iface;
uint16_t vrf_id;
struct ip_local_mbuf_data *ip_data;

for (uint16_t i = 0; i < nb_objs; i++) {
mbuf = objs[i];
Expand All @@ -50,8 +53,7 @@ ip_ttl_exceeded(struct rte_graph *graph, struct rte_node *node, void **objs, uin

// RFC792 payload size: ip header + 64 bits of original datagram
ip_data->len = sizeof(struct rte_icmp_hdr)
+ RTE_MIN(sizeof(struct rte_ipv4_hdr) + 8,
rte_be_to_cpu_16(ip->total_length));
+ RTE_MIN(rte_ipv4_hdr_len(ip) + 8, rte_be_to_cpu_16(ip->total_length));
ip_data->proto = IPPROTO_ICMP;

icmp->icmp_type = GR_IP_ICMP_TTL_EXCEEDED;
Expand All @@ -60,15 +62,15 @@ ip_ttl_exceeded(struct rte_graph *graph, struct rte_node *node, void **objs, uin
icmp->icmp_ident = 0;
icmp->icmp_seq_nb = 0;

rte_node_enqueue_x1(graph, node, next, mbuf);
rte_node_enqueue_x1(graph, node, ICMP_OUTPUT, mbuf);
}

return nb_objs;
}

struct rte_node_register ip_ttl_exceeded_node = {
.name = "ip_ttl_exceeded",
.process = ip_ttl_exceeded,
.process = ip_ttl_exceeded_process,
.nb_edges = EDGE_COUNT,
.next_nodes = {
[ICMP_OUTPUT] = "icmp_output",
Expand Down

0 comments on commit 2f64ace

Please sign in to comment.