summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX/packet_utils.c
diff options
context:
space:
mode:
authorXavier Simonart <xavier.simonart@intel.com>2018-12-13 12:52:02 +0100
committerXavier Simonart <xavier.simonart@intel.com>2019-01-28 12:14:20 +0100
commitfd72a6505e18c66a31843708bb69a41739b97a84 (patch)
tree299d281a1d229282560588250a888d30ea6bb61b /VNFs/DPPD-PROX/packet_utils.c
parent8bffdf8c09100f8a923c37bd9be39a13cbc49862 (diff)
Add support for configurable arp timers in L3 mode
L3 mode supports two timers: - arp_update_time, defaulted to 1 second, which makes PROX to send arp request every second for active flows - arp_timeout, previously defaulted to 30 seconds, which makes PROX consider a MAC address as invalid if no arp_reply was received within those 30 seconds. Those timers values were hardcoded. They can now be configured through the configuration file (within the core section), using resp. "arp update time" and "arp timeout" keywords. Unit is milli seconds. The default becomes respectively 1 second and 2 weeks. Change-Id: I35e46e97df32ca44c2cdfae85a20ee015de5d6e1 Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
Diffstat (limited to 'VNFs/DPPD-PROX/packet_utils.c')
-rw-r--r--VNFs/DPPD-PROX/packet_utils.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/VNFs/DPPD-PROX/packet_utils.c b/VNFs/DPPD-PROX/packet_utils.c
index e93f430c..6c3da0ec 100644
--- a/VNFs/DPPD-PROX/packet_utils.c
+++ b/VNFs/DPPD-PROX/packet_utils.c
@@ -89,7 +89,7 @@ int write_dst_mac(struct task_base *tbase, struct rte_mbuf *mbuf, uint32_t *ip_d
return SEND_MBUF;
} else if (tsc > l3->gw.arp_update_time) {
// long time since we have sent an arp, send arp
- l3->gw.arp_update_time = tsc + hz;
+ l3->gw.arp_update_time = tsc + l3->arp_update_time * hz / 1000;
*ip_dst = l3->gw.ip;
if ((l3->flags & FLAG_DST_MAC_KNOWN) && (tsc < l3->gw.arp_timeout)){
// MAC is valid in the table => send also the mbuf
@@ -120,7 +120,7 @@ int write_dst_mac(struct task_base *tbase, struct rte_mbuf *mbuf, uint32_t *ip_d
return SEND_MBUF;
} else if (tsc > l3->optimized_arp_table[idx].arp_update_time) {
// ARP not sent since a long time, send ARP
- l3->optimized_arp_table[idx].arp_update_time = tsc + hz;
+ l3->optimized_arp_table[idx].arp_update_time = tsc + l3->arp_update_time * hz / 1000;
if (tsc < l3->optimized_arp_table[idx].arp_timeout) {
// MAC still valid => also send mbuf
memcpy(mac, &l3->optimized_arp_table[idx].mac, sizeof(struct ether_addr));
@@ -137,7 +137,7 @@ int write_dst_mac(struct task_base *tbase, struct rte_mbuf *mbuf, uint32_t *ip_d
}
// IP address not found in table
l3->optimized_arp_table[l3->n_pkts].ip = *ip_dst;
- l3->optimized_arp_table[l3->n_pkts].arp_update_time = tsc + hz;
+ l3->optimized_arp_table[l3->n_pkts].arp_update_time = tsc + l3->arp_update_time * hz / 1000;
l3->n_pkts++;
if (l3->n_pkts < 4) {
@@ -171,7 +171,7 @@ int write_dst_mac(struct task_base *tbase, struct rte_mbuf *mbuf, uint32_t *ip_d
return DROP_MBUF;
} else {
l3->arp_table[ret].ip = *ip_dst;
- l3->arp_table[ret].arp_update_time = tsc + hz;
+ l3->arp_table[ret].arp_update_time = tsc + l3->arp_update_time * hz / 1000;
}
return SEND_ARP;
} else {
@@ -182,6 +182,7 @@ int write_dst_mac(struct task_base *tbase, struct rte_mbuf *mbuf, uint32_t *ip_d
return SEND_MBUF;
} else if (tsc > l3->arp_table[ret].arp_update_time) {
// ARP not sent since a long time, send ARP
+ l3->arp_table[ret].arp_update_time = tsc + l3->arp_update_time * hz / 1000;
l3->arp_table[ret].arp_update_time = tsc + hz;
if (tsc < l3->arp_table[ret].arp_timeout) {
// MAC still valid => send also MBUF
@@ -229,6 +230,14 @@ void task_init_l3(struct task_base *tbase, struct task_args *targ)
tbase->l3.core_id = targ->lconf->id;
tbase->l3.task_id = targ->id;
tbase->l3.tmaster = targ->tmaster;
+ if (tbase->l3.arp_timeout != 0)
+ tbase->l3.arp_timeout = targ->arp_timeout;
+ else
+ tbase->l3.arp_timeout = DEFAULT_ARP_TIMEOUT;
+ if (tbase->l3.arp_update_time != 0)
+ tbase->l3.arp_update_time = targ->arp_update_time;
+ else
+ tbase->l3.arp_update_time = DEFAULT_ARP_UPDATE_TIME;
}
void task_start_l3(struct task_base *tbase, struct task_args *targ)
@@ -299,7 +308,7 @@ void handle_ctrl_plane_pkts(struct task_base *tbase, struct rte_mbuf **mbufs, ui
// MAC address of the gateway
memcpy(&l3->gw.mac, &hdr->arp.data.sha, 6);
l3->flags |= FLAG_DST_MAC_KNOWN;
- l3->gw.arp_timeout = tsc + 30 * hz;
+ l3->gw.arp_timeout = tsc + l3->arp_timeout * hz / 1000;
} else if (l3->n_pkts < 4) {
// Few packets tracked - should be faster to loop through them thean using a hash table
for (idx = 0; idx < l3->n_pkts; idx++) {
@@ -310,7 +319,7 @@ void handle_ctrl_plane_pkts(struct task_base *tbase, struct rte_mbuf **mbufs, ui
if (idx < l3->n_pkts) {
// IP not found; this is a reply while we never asked for the request!
memcpy(&l3->optimized_arp_table[idx].mac, &(hdr->arp.data.sha), sizeof(struct ether_addr));
- l3->optimized_arp_table[idx].arp_timeout = tsc + 30 * hz;
+ l3->optimized_arp_table[idx].arp_timeout = tsc + l3->arp_timeout * hz / 1000;
}
} else {
int ret = rte_hash_add_key(l3->ip_hash, (const void *)&ip);
@@ -318,7 +327,7 @@ void handle_ctrl_plane_pkts(struct task_base *tbase, struct rte_mbuf **mbufs, ui
plogx_info("Unable add ip %d.%d.%d.%d in mac_hash\n", IP4(ip));
} else {
memcpy(&l3->arp_table[ret].mac, &(hdr->arp.data.sha), sizeof(struct ether_addr));
- l3->arp_table[ret].arp_timeout = tsc + 30 * hz;
+ l3->arp_table[ret].arp_timeout = tsc + l3->arp_timeout * hz / 1000;
}
}
tx_drop(mbufs[j]);