diff options
author | Xavier Simonart <xavier.simonart@intel.com> | 2017-12-11 13:15:58 +0100 |
---|---|---|
committer | Xavier Simonart <xavier.simonart@intel.com> | 2018-01-04 16:18:34 +0100 |
commit | 35bf01ebc2139ad51caa77c22f5e67f8709e699f (patch) | |
tree | e080758394b64b71d5d631cc401cc6010ca550ed /VNFs/DPPD-PROX | |
parent | d00ce88ca11ee2730126d2e8bd491361cb491674 (diff) |
Add config option to use port mac as src mac in l2fwd and swap
L2fwd and swap has many options to set src mac. swap was supposed
to support the ability to use port mac, but config file parsing was
wrong. L2fwd was using port mac if a port was available and if
src mac=packet or if there was no src mac in the config.
Now l2fwd supports the following options
- "src mac=xx:xx:xx:xx:xx:xx" => this mac address is used as src mac.
- "src mac=packet" => the src mac is taken from the dst mac of the
received packet.
- "src mac=hw" => the src mac is taken from the mac address of the port,
if there is a physical port. Error otherwise.
- "src mac=no" => src mac kept untouched
- No "src mac" => same as "src mac=hw" if there is a physical port
and same as "src mac=packet" otherwise.
Default is (no "src mac") hence the mac is taken from the tx port if there
is one tx port and from the packet otherwise.
swap support is similar, except that it does not support "src mac=no".
Change-Id: I70fe49a61c2e85772288b769ede14a7a6205d122
Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
Diffstat (limited to 'VNFs/DPPD-PROX')
-rw-r--r-- | VNFs/DPPD-PROX/handle_l2fwd.c | 28 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/handle_swap.c | 36 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/prox_args.c | 2 |
3 files changed, 39 insertions, 27 deletions
diff --git a/VNFs/DPPD-PROX/handle_l2fwd.c b/VNFs/DPPD-PROX/handle_l2fwd.c index 79a5f02e..faebe6fb 100644 --- a/VNFs/DPPD-PROX/handle_l2fwd.c +++ b/VNFs/DPPD-PROX/handle_l2fwd.c @@ -69,17 +69,21 @@ static void init_task_l2fwd(struct task_base *tbase, struct task_args *targ) struct ether_addr *src_addr, *dst_addr; /* - * Destination MAC can come from - * - pre-configured mac in case 'dst mac=xx:xx:xx:xx:xx:xx' in config file - * - src mac from the packet in case 'dst mac=packet' in config file - * - not written in case 'dst mac=no' in config file - * - (default - no 'dst mac') src mac from the packet - * Source MAC can come from - * - pre-configured mac in case 'src mac=xx:xx:xx:xx:xx:xx' in config file - * - dst mac from the packet in case 'src mac=packet' in config file - * - not written in case 'src mac=no' in config file - * - (default - no 'src mac') if (tx_port) port mac - * - (default - no 'src mac') if (no tx_port) dst mac from the packet + * The destination MAC of the outgoing packet is based on the config file: + * - 'dst mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as dst mac + * - 'dst mac=packet' => the src mac of the incoming packet is used as dst mac + * - 'dst mac=no' => the dst mac is untouched + * - (default - no 'dst mac') => the src mac from the incoming packet is used as dst mac + * + * The source MAC of the outgoing packet is based on the config file: + * - 'src mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as src mac + * - 'src mac=packet' => the dst mac of the incoming packet is used as src mac + * - 'src mac=hw' => the mac address of the tx port is used as src mac + * An error is returned if there are no physical tx ports + * - 'src mac=no' => the src mac is untouched + * - (default - no 'src mac') => if there is physical tx port, the mac of that port is used as src mac + * - (default - no 'src mac') if there are no physical tx ports the dst mac of the incoming packet + is used as src mac */ if (targ->flags & TASK_ARG_DST_MAC_SET) { @@ -92,6 +96,8 @@ static void init_task_l2fwd(struct task_base *tbase, struct task_args *targ) memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr)); plog_info("\t\tCore %d: src mac set from config file\n", targ->lconf->id); } else if ((targ->flags & TASK_ARG_DO_NOT_SET_SRC_MAC) == 0) { + if (targ->flags & TASK_ARG_HW_SRC_MAC) + PROX_PANIC(targ->nb_txports == 0, "src mac set to hw but no tx port\n"); if (targ->nb_txports) { src_addr = &prox_port_cfg[task->base.tx_params_hw.tx_port_queue[0].port].eth_addr; targ->flags |= TASK_ARG_SRC_MAC_SET; diff --git a/VNFs/DPPD-PROX/handle_swap.c b/VNFs/DPPD-PROX/handle_swap.c index 516d3f63..68dfe2b4 100644 --- a/VNFs/DPPD-PROX/handle_swap.c +++ b/VNFs/DPPD-PROX/handle_swap.c @@ -203,17 +203,18 @@ static void init_task_swap(struct task_base *tbase, struct task_args *targ) struct ether_addr *src_addr, *dst_addr; /* - * Destination MAC can come from - * - pre-configured mac in case 'dst mac=xx:xx:xx:xx:xx:xx' in config file - * - src mac from the packet in case 'dst mac=packet' in config file - * - not written in case 'dst mac=no' in config file - * - (default - no 'dst mac') src mac from the packet - * Source MAC can come from - * - pre-configured mac in case 'src mac=xx:xx:xx:xx:xx:xx' in config file - * - dst mac from the packet in case 'src mac=packet' in config file - * - not written in case 'src mac=no' in config file - * - (default - no 'src mac') if (tx_port) port mac - * - (default - no 'src mac') if (no tx_port) dst mac from the packet + * The destination MAC of the outgoing packet is based on the config file: + * - 'dst mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as dst mac + * - 'dst mac=packet' => the src mac of the incoming packet is used as dst mac + * - (default - no 'dst mac') => the src mac from the incoming packet is used as dst mac + * + * The source MAC of the outgoing packet is based on the config file: + * - 'src mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as src mac + * - 'src mac=packet' => the dst mac of the incoming packet is used as src mac + * - 'src mac=hw' => the mac address of the tx port is used as src mac + * An error is returned if there are no physical tx ports + * - (default - no 'src mac') => if there is physical tx port, the mac of that port is used as src mac + * - (default - no 'src mac') if there are no physical tx ports the dst mac of the incoming packet */ if (targ->flags & TASK_ARG_DST_MAC_SET) { @@ -221,14 +222,19 @@ static void init_task_swap(struct task_base *tbase, struct task_args *targ) memcpy(&task->src_dst_mac[0], dst_addr, sizeof(*src_addr)); } + PROX_PANIC(targ->flags & TASK_ARG_DO_NOT_SET_SRC_MAC, "src mac must be set in swap mode, by definition => src mac=no is not supported\n"); + PROX_PANIC(targ->flags & TASK_ARG_DO_NOT_SET_DST_MAC, "dst mac must be set in swap mode, by definition => dst mac=no is not supported\n"); + if (targ->flags & TASK_ARG_SRC_MAC_SET) { src_addr = &targ->esaddr; memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr)); plog_info("\t\tCore %d: src mac set from config file\n", targ->lconf->id); - } else if (targ->nb_txports) { - src_addr = &prox_port_cfg[task->base.tx_params_hw.tx_port_queue[0].port].eth_addr; - memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr)); - if (targ->flags & TASK_ARG_HW_SRC_MAC){ + } else { + if (targ->flags & TASK_ARG_HW_SRC_MAC) + PROX_PANIC(targ->nb_txports == 0, "src mac set to hw but no tx port\n"); + if (targ->nb_txports) { + src_addr = &prox_port_cfg[task->base.tx_params_hw.tx_port_queue[0].port].eth_addr; + memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr)); targ->flags |= TASK_ARG_SRC_MAC_SET; plog_info("\t\tCore %d: src mac set from port\n", targ->lconf->id); } diff --git a/VNFs/DPPD-PROX/prox_args.c b/VNFs/DPPD-PROX/prox_args.c index bbe27382..e6d2f83e 100644 --- a/VNFs/DPPD-PROX/prox_args.c +++ b/VNFs/DPPD-PROX/prox_args.c @@ -1292,7 +1292,7 @@ static int get_core_cfg(unsigned sindex, char *str, void *data) } else if (STR_EQ(pkey, "packet")) return 0; - else if (STR_EQ(pkey, "packet")) { + else if (STR_EQ(pkey, "hw")) { targ->flags |= TASK_ARG_HW_SRC_MAC; return 0; } else { |