Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infra: add drop counter "no_headroom" #22

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/infra/datapath/drop.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ drop_packets(struct rte_graph *graph, struct rte_node *node, void **objs, uint16

return nb_objs;
}

// Global drop counters, used by multiple nodes
GR_DROP_REGISTER(error_no_headroom);
10 changes: 10 additions & 0 deletions modules/infra/datapath/eth_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
enum {
TX = 0,
INVAL,
NO_HEADROOM,
NB_EDGES,
};

Expand All @@ -38,6 +39,10 @@ eth_output_process(struct rte_graph *graph, struct rte_node *node, void **objs,
case GR_IFACE_TYPE_VLAN:
sub = (struct iface_info_vlan *)priv->iface->info;
vlan = (struct rte_vlan_hdr *)rte_pktmbuf_prepend(mbuf, sizeof(*vlan));
if (unlikely(vlan == NULL)) {
rte_node_enqueue_x1(graph, node, NO_HEADROOM, mbuf);
continue;
}
vlan->vlan_tci = rte_cpu_to_be_16(sub->vlan_id);
vlan->eth_proto = priv->ether_type;
priv->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
Expand All @@ -55,6 +60,10 @@ eth_output_process(struct rte_graph *graph, struct rte_node *node, void **objs,
}

eth = (struct rte_ether_hdr *)rte_pktmbuf_prepend(mbuf, sizeof(*eth));
if (unlikely(eth == NULL)) {
rte_node_enqueue_x1(graph, node, NO_HEADROOM, mbuf);
continue;
}
rte_ether_addr_copy(&priv->dst, &eth->dst_addr);
rte_ether_addr_copy(src_mac, &eth->src_addr);
eth->ether_type = priv->ether_type;
Expand All @@ -75,6 +84,7 @@ static struct rte_node_register node= {
.next_nodes = {
[TX] = "port_tx",
[INVAL] = "eth_output_inval",
[NO_HEADROOM] = "error_no_headroom",
},
};

Expand Down
9 changes: 7 additions & 2 deletions modules/ip/datapath/icmp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

enum {
OUTPUT = 0,
NO_HEADROOM,
EDGE_COUNT,
};

Expand All @@ -35,14 +36,17 @@ icmp_output_process(struct rte_graph *graph, struct rte_node *node, void **objs,
icmp->icmp_cksum = ~rte_raw_cksum(icmp, local_data->len);

ip = (struct rte_ipv4_hdr *)rte_pktmbuf_prepend(mbuf, sizeof(*ip));
if (unlikely(ip == NULL)) {
rte_node_enqueue_x1(graph, node, NO_HEADROOM, mbuf);
continue;
}
ip_set_fields(ip, local_data);
ip_output_mbuf_data(mbuf)->nh = ip4_route_lookup(
local_data->vrf_id, local_data->dst
);
rte_node_enqueue_x1(graph, node, OUTPUT, mbuf);
}

rte_node_enqueue(graph, node, OUTPUT, objs, nb_objs);

return nb_objs;
}

Expand All @@ -54,6 +58,7 @@ static struct rte_node_register icmp_output_node = {
.nb_edges = EDGE_COUNT,
.next_nodes = {
[OUTPUT] = "ip_output",
[NO_HEADROOM] = "error_no_headroom",
},
};

Expand Down
6 changes: 6 additions & 0 deletions modules/ipip/datapath_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
enum {
IP_OUTPUT = 0,
NO_TUNNEL,
NO_HEADROOM,
EDGE_COUNT,
};

Expand Down Expand Up @@ -56,6 +57,10 @@ ipip_output_process(struct rte_graph *graph, struct rte_node *node, void **objs,
tunnel.vrf_id = iface->vrf_id;
tunnel.proto = IPPROTO_IPIP;
outer = (struct rte_ipv4_hdr *)rte_pktmbuf_prepend(mbuf, sizeof(*outer));
if (unlikely(outer == NULL)) {
rte_node_enqueue_x1(graph, node, NO_HEADROOM, mbuf);
continue;
}
ip_set_fields(outer, &tunnel);

// Resolve nexthop for the encapsulated packet.
Expand Down Expand Up @@ -84,6 +89,7 @@ static struct rte_node_register ipip_output_node = {
.next_nodes = {
[IP_OUTPUT] = "ip_output",
[NO_TUNNEL] = "ipip_output_no_tunnel",
[NO_HEADROOM] = "error_no_headroom",
},
};

Expand Down