-
Notifications
You must be signed in to change notification settings - Fork 26
Could this compiler support XDP_REDIRECT #110
Comments
The work in the compiler to support XDP_REDIRECT is very simple. |
In fact, no work in the compiler is needed. You can just add XDP_REDIRECT to the p4include/xdp_model.p4 file and it will produce the right C. I will submit a PR. However, I still don't know how you should use it. |
Thank you for your prompt reply. if(hd.ipv4.isValid())
{
dstmactable.apply();
xout.output_port = 0;
xout.output_action = xoutdrop ? xdp_action.XDP_DROP : xdp_action.XDP_REDIRECT;
} and the generated xdp5.c file : xout.output_port = 0;
if (xoutdrop_0)
tmp = XDP_DROP;
else
tmp = XDP_REDIRECT;
xout.output_action = tmp; However, I cannot capture any transmitted packets . And then I did another test to set the out_port as 1 and output_action as XDP_REDIRECT to see if I can capture packets in the eth1. Unfortunately still cannot. Thank you for your attention to this matter. It would be nice if you could provide a bit more information on this question. |
Hi, XDP_REDIRECT requires using a map, ebpf_outTable, to lookup the output port. Are you able to see the contents in the ebpf_outTable? ex: by using the bpftool? |
Thank you for your prompt reply. bpftool map dump pinned /sys/fs/bpf/xdp/globals/ebpf_outTable the output is key:
00 00 00 00
value (CPU 00): 00 00 00 00
value (CPU 01): 01 00 00 00
value (CPU 02): 00 00 00 00
value (CPU 03): 00 00 00 00
value (CPU 04): 00 00 00 00
value (CPU 05): 00 00 00 00
value (CPU 06): 00 00 00 00
value (CPU 07): 00 00 00 00
Found 1 element Do you have any simple examples that using TC cooperating with xdp program generated by P4C-XDP to send raw packets from one NIC to another . The xdp program just pass packets. Then TC receives the packets and send to another NIC. |
Actually the ebpf_outTable only has one entry in the xdp.c file. And how to specify the max_entries of this map in P4 program? Do you know how to specify which NIC to send packets in P4 program ? |
So looking into more details, XDP_REDIRECT is not fully supported now. The reason we did this is because at the time we started the project, there is no XDP_REDIRECT support. In this way, we don't need TC to send packet, the packet will be handled at XDP layer. |
hash_table(64), example below:
to send to a nic, get the nic's ifindex, and program the <key, value> to <port, ifindex> into the
|
Hi, |
Yes, the hash_table(64) can appoint the dstmactable's max entries. Actually I want to specify the max entries of ebpf_outTable. However, it seems that there is no method to specify this in P4 program .
action Fallback_action {
xout.output_port = 8;
xout.output_action = XDP_PASS;
}
table dstmactable {
key = { hd.ipv4.dstAddr : exact; }
actions = {
Fallback_action;
Drop_action;
}
default_action = Drop_action;
implementation = hash_table(64);
} the table entry is
It means that once a packet whose dst IP address is 10.0.0.1 from eth0 arrives at XDP layer, the XDP program will match the first entry of dstmactable and set output_port = 8 and pass the packet to TC layer. And all this actions don't have effect on the ebpf_outTable.
the 8 is the output port number which P4 program sets. And 666 is the eth8's ifindex.
And here is the question: |
I don't have an exactly working example, but you can follow this sample code |
TC doesn't need to know key is 8, all TC does is to get the first entry in the map and output the packet to the ifindex 888. |
Hi, |
Technically I don't think any changes need to be made in the compiler; it's probably just the control-plane setup that needs to be adapted. I personally don't have a machine where I can test XDP; I don't know if @williamtu has time to build an example. |
Using code generated by p4c-xdp, I was not able to redirect. |
Can you contribute an example? |
The XDP_TX return code only support to send the packets to the same NIC card . And XDP_REDIRECT can send the received packets to another NIC . However , this compiler seems not to implement XDP_REDIRECT ? Is there any other way to implement forwarding function from one nic like eth1 to another NIC like eth2 using P4C-XDP compiler?
I notice that the xdp_model.p4 has defined xdp_output:
As for the output_port , is it used to appoint the different NIC id?
The text was updated successfully, but these errors were encountered: