#include "quit.h"
#define BYTE_VALUE_MAX 256
-#define ALL_32_BITS 0xffffffff
-#define BIT_8_TO_15 0x0000ff00
+#define BIT_8_TO_10 0x0000e000 // for protocol field
+#define BIT_27_TO_31 0x1f000000 // for IP addresses
+#define BIT_12_TO_16_27_TO_31 0x1f001f00 // for ports
#define HASH_MAX_SIZE 4*8*1024*1024
int ret = 0;
union ipv4_5tuple_host key;
- ipv4_hdr = (uint8_t *)ipv4_hdr + offsetof(struct ipv4_hdr, time_to_live);
+ ipv4_hdr = (uint8_t *)ipv4_hdr + offsetof(prox_rte_ipv4_hdr, time_to_live);
__m128i data = _mm_loadu_si128((__m128i*)(ipv4_hdr));
/* Get 5 tuple: dst port, src port, dst IP address, src IP address and protocol */
- key.xmm = _mm_and_si128(data, mask0);
+ key.xmm = _mm_and_si128(data, mask0);
/* Get 5 tuple: dst port, src port, dst IP address, src IP address and protocol */
/*
static inline uint8_t handle_lb_5tuple(struct task_lb_5tuple *task, struct rte_mbuf *mbuf)
{
- struct ether_hdr *eth_hdr;
- struct ipv4_hdr *ipv4_hdr;
+ prox_rte_ether_hdr *eth_hdr;
+ prox_rte_ipv4_hdr *ipv4_hdr;
- eth_hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr *);
+ eth_hdr = rte_pktmbuf_mtod(mbuf, prox_rte_ether_hdr *);
switch (eth_hdr->ether_type) {
case ETYPE_IPv4:
/* Handle IPv4 headers.*/
- ipv4_hdr = (struct ipv4_hdr *) (eth_hdr + 1);
+ ipv4_hdr = (prox_rte_ipv4_hdr *) (eth_hdr + 1);
return get_ipv4_dst_port(task, ipv4_hdr, OUT_DISCARD, task->lookup_hash);
default:
return OUT_DISCARD;
struct task_lb_5tuple *task = (struct task_lb_5tuple *)tbase;
const int socket_id = rte_lcore_to_socket_id(targ->lconf->id);
- mask0 = _mm_set_epi32(ALL_32_BITS, ALL_32_BITS, ALL_32_BITS, BIT_8_TO_15);
-
+ mask0 = _mm_set_epi32(BIT_12_TO_16_27_TO_31, BIT_27_TO_31, BIT_27_TO_31, BIT_8_TO_10);
uint8_t *out_table = task->out_if;
int ret = lua_to_tuples(prox_lua(), GLOBAL, "tuples", socket_id, &task->lookup_hash, &out_table);
PROX_PANIC(ret, "Failed to read tuples from config\n");