Commit 16e9f20e authored by Leonardo Lai's avatar Leonardo Lai

l4 switching of received packets

small improvements to logging
parent fe0b1a39
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
#include "udpdk_lookup_table.h" #include "udpdk_lookup_table.h"
#include "udpdk_types.h" #include "udpdk_types.h"
#define RTE_LOGTYPE_POLLBODY RTE_LOGTYPE_USER1
#define RTE_LOGTYPE_POLLINIT RTE_LOGTYPE_USER1 #define RTE_LOGTYPE_POLLINIT RTE_LOGTYPE_USER1
#define RTE_LOGTYPE_POLLINTR RTE_LOGTYPE_USER1
static volatile int poller_alive = 1; static volatile int poller_alive = 1;
...@@ -55,7 +57,7 @@ static struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE]; ...@@ -55,7 +57,7 @@ static struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE];
/* Poller signal handler */ /* Poller signal handler */
static void poller_sighandler(int sig) static void poller_sighandler(int sig)
{ {
printf("Poller: received request to stop\n"); RTE_LOG(INFO, POLLINTR, "Received request to stop\n");
poller_alive = 0; poller_alive = 0;
} }
...@@ -154,6 +156,7 @@ static int setup_udp_table(void) ...@@ -154,6 +156,7 @@ static int setup_udp_table(void)
return -1; return -1;
} }
udp_port_table = udp_port_table_mz->addr; udp_port_table = udp_port_table_mz->addr;
return 0; return 0;
} }
...@@ -258,7 +261,7 @@ static inline void reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queu ...@@ -258,7 +261,7 @@ static inline void reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queu
struct rx_queue *rxq; struct rx_queue *rxq;
uint16_t udp_dst_port; uint16_t udp_dst_port;
uint32_t ip_dst; uint32_t ip_dst;
static int foo = 0; // TODO dummy int sock_id;
rxq = &qconf->rx_queue; rxq = &qconf->rx_queue;
...@@ -292,12 +295,12 @@ static inline void reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queu ...@@ -292,12 +295,12 @@ static inline void reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queu
} }
} }
} else { } else {
printf("[WARN] Received non-IPv4 packet.\n"); RTE_LOG(WARNING, POLLBODY, "Received non-IPv4 packet.\n");
return; return;
} }
if (!is_udp_pkt(ip_hdr)) { if (!is_udp_pkt(ip_hdr)) {
printf("[WARN] Received non-UDP packet.\n"); RTE_LOG(WARNING, POLLBODY, "Received non-UDP packet.\n");
return; return;
} }
udp_dst_port = get_udp_dst_port( udp_dst_port = get_udp_dst_port(
...@@ -309,13 +312,14 @@ static inline void reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queu ...@@ -309,13 +312,14 @@ static inline void reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queu
printf("[DBG] UDP dest port: %d\n", udp_dst_port); // TODO DEBUG printf("[DBG] UDP dest port: %d\n", udp_dst_port); // TODO DEBUG
printf("[DBG] IP dest addr: %s\n", ip_str); // TODO DEBUG printf("[DBG] IP dest addr: %s\n", ip_str); // TODO DEBUG
// TODO based on UDP, find the appropriate exchange buffer // Find the sock_id corresponding to the UDP dst port (L4 switching) and enqueue the packet to its queue
// TODO here enqueuing is a dummy round-robin, not based on actual port! sock_id = htable_lookup(udp_port_table, udp_dst_port);
if (foo & 1) { if (sock_id < 0 || sock_id >= NUM_SOCKETS_MAX) {
enqueue_rx_packet(1, m); errno = EINVAL;
} else { RTE_LOG(ERR, POLLBODY, "Invalid L4 port mapping: port %d maps to sock_id %d\n", udp_dst_port, sock_id);
enqueue_rx_packet(0, m); return;
} }
enqueue_rx_packet(sock_id, m);
} }
/* Packet polling routine */ /* Packet polling routine */
......
...@@ -126,6 +126,7 @@ int udpdk_bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) ...@@ -126,6 +126,7 @@ int udpdk_bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
// Insert in the hashtable (port, sock_id) // Insert in the hashtable (port, sock_id)
htable_insert(udp_port_table, (int)port, sockfd); htable_insert(udp_port_table, (int)port, sockfd);
RTE_LOG(INFO, SYSCALL, "Binding port %d to sock_id %d\n", port, sockfd);
return 0; return 0;
} }
...@@ -217,7 +218,6 @@ ssize_t udpdk_recvfrom(int sockfd, void *buf, size_t len, int flags, ...@@ -217,7 +218,6 @@ ssize_t udpdk_recvfrom(int sockfd, void *buf, size_t len, int flags,
struct rte_udp_hdr *udp_hdr; struct rte_udp_hdr *udp_hdr;
void *udp_data; void *udp_data;
printf("Inside recvfrom\n");
// Validate the arguments // Validate the arguments
if (recvfrom_validate_args(sockfd, buf, len, flags, src_addr, addrlen) < 0) { if (recvfrom_validate_args(sockfd, buf, len, flags, src_addr, addrlen) < 0) {
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment