Closed strongcourage closed 3 years ago
What's your expectation & your code modification?
I'd like to implement a simple Load Balancer NF on VM1 that has 3 DPDK ports. The LB will send only packets from source IP1 to VM2, and only packets from source IP2 to VM3. On VM2 and VM3, there are different NFs that process those incoming packets.
I think I can adapt the bridge NF example to implement the LB, but it seems that it didn't work. Thank you.
struct rte_ipv4_hdr *ipv4_hdr;
char ip_string[16];
if (pkt->port == 0) {
if (onvm_pkt_is_ipv4(pkt)) {
ipv4_hdr = onvm_pkt_ipv4_hdr(pkt);
onvm_pkt_parse_char_ip(ip_string, rte_be_to_cpu_32(ipv4_hdr->src_addr));
if (strncmp(ip_string, "192.168.", strlen("192.168.")) == 0) {
meta->destination = 1;
meta->action = ONVM_NF_ACTION_OUT;
RTE_LOG(INFO, APP, "Send packet from source IP %s to port %d\n", ip_string, meta->destination);
} else {
meta->destination = 2;
meta->action = ONVM_NF_ACTION_OUT;
RTE_LOG(INFO, APP, "Send packet from source IP %s to port %d\n", ip_string, meta->destination);
}
} else {
meta->destination = 0;
meta->action = ONVM_NF_ACTION_DROP;
}
}
else {
meta->destination = 0;
meta->action = ONVM_NF_ACTION_DROP;
}
@strongcourage - the logic in your code seems fine to me. Have you double checked that the port numbers are what you expect (i.e. look at the manager output and compare the MAC addresses so you know which port is which)?
Can you describe what happens when you run your code?
Thanks, Tim. It seems work when I set 2 different types of network adapter (Internal Network for DPDK-NIC2 and NAT Network for DPDK-NIC3) on VM1. If not, packets will be sent from port 0 to both ports 1 and 2.
Hi all,
I'm trying to modify the bridge example so that only packets from a given IP address will be sent from port 0 to port 1. Here there are 3 DPDK ports. By running the bridge example, I get the following result:
I don't understand why TX of port 1 and RX of port 2 have those values (not 0). Does
meta->destination
correspond to the port ID, e.g., 0, 1, 2 ? In case where there are multiple ports, how can I only send packets to port 1 ? Thank you.