Skip to content

Commit 8648af1

Browse files
committed
ip: fix loopback input detection
In commit e5570d2 ("policy: add stateful dynamic source nat support"), the assignment ip_output_mbuf_data(mbuf)->nh = nh was moved earlier in the processing path. This assignment overwrites the mbuf metadata that e points to, since eth_input_mbuf_data and ip_output_mbuf_data share the same memory area. As a result, accessing e->domain after this assignment reads garbage data, causing incorrect routing decisions when checking whether a packet should be sent to ip_output directly versus being forwarded. Cache the domain value in a local variable before the mbuf metadata is overwritten to ensure the correct routing decision is made. Fixes: e5570d2 ("policy: add stateful dynamic source nat support") Signed-off-by: Robin Jarry <rjarry@redhat.com>
1 parent 0a7d30c commit 8648af1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

modules/ip/datapath/ip_input.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ ip_input_process(struct rte_graph *graph, struct rte_node *node, void **objs, ui
5050
const struct nexthop *nh;
5151
struct rte_ipv4_hdr *ip;
5252
struct rte_mbuf *mbuf;
53+
eth_domain_t domain;
5354
rte_edge_t edge;
5455
uint16_t i;
5556

5657
for (i = 0; i < nb_objs; i++) {
5758
mbuf = objs[i];
5859
ip = rte_pktmbuf_mtod(mbuf, struct rte_ipv4_hdr *);
5960
e = eth_input_mbuf_data(mbuf);
61+
domain = e->domain;
6062
iface = e->iface;
6163
nh = NULL;
6264

@@ -111,7 +113,7 @@ ip_input_process(struct rte_graph *graph, struct rte_node *node, void **objs, ui
111113
goto next;
112114
}
113115

114-
switch (e->domain) {
116+
switch (domain) {
115117
case ETH_DOMAIN_LOOPBACK:
116118
case ETH_DOMAIN_LOCAL:
117119
// Packet sent to our ethernet address.
@@ -143,7 +145,7 @@ ip_input_process(struct rte_graph *graph, struct rte_node *node, void **objs, ui
143145

144146
// If the resolved next hop is local and the destination IP is ourselves,
145147
// send to ip_local.
146-
if (e->domain == ETH_DOMAIN_LOOPBACK)
148+
if (domain == ETH_DOMAIN_LOOPBACK)
147149
edge = OUTPUT;
148150
else if (nh->type == GR_NH_T_L3) {
149151
l3 = nexthop_info_l3(nh);

0 commit comments

Comments
 (0)