Skip to content

Commit

Permalink
Make pf1-proxy a command-line argument
Browse files Browse the repository at this point in the history
  • Loading branch information
PlagueCZ committed Oct 3, 2024
1 parent 80171b8 commit 6411090
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 15 deletions.
1 change: 1 addition & 0 deletions docs/deployment/help_dpservice-bin.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
| -v, --version | None | display version and exit | |
| --pf0 | IFNAME | first physical interface (e.g. eth0) | |
| --pf1 | IFNAME | second physical interface (e.g. eth1) | |
| --pf1-proxy | IFNAME | VF representor to use as a proxy for pf1 packets | |
| --ipv6 | ADDR6 | IPv6 underlay address | |
| --vf-pattern | PATTERN | virtual interface name pattern (e.g. 'eth1vf') | |
| --dhcp-mtu | SIZE | set the mtu field in DHCP responses (68 - 1500) | |
Expand Down
9 changes: 9 additions & 0 deletions hack/dp_conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
"type": "char",
"array_size": "IF_NAMESIZE"
},
{
"lgopt": "pf1-proxy",
"arg": "IFNAME",
"help": "VF representor to use as a proxy for pf1 packets",
"var": "pf1_proxy",
"type": "char",
"array_size": "IF_NAMESIZE",
"ifdef": "ENABLE_PF1_PROXY"
},
{
"lgopt": "ipv6",
"arg": "ADDR6",
Expand Down
1 change: 0 additions & 1 deletion include/dp_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const struct dp_conf_dhcp_dns *dp_conf_get_dhcp_dns(void);
const struct dp_conf_dhcp_dns *dp_conf_get_dhcpv6_dns(void);

#ifdef ENABLE_PF1_PROXY
const char *dp_conf_get_pf1_proxy(void);
bool dp_conf_is_pf1_proxy_enabled(void);
#endif

Expand Down
3 changes: 3 additions & 0 deletions include/dp_conf_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ enum dp_conf_log_format {

const char *dp_conf_get_pf0_name(void);
const char *dp_conf_get_pf1_name(void);
#ifdef ENABLE_PF1_PROXY
const char *dp_conf_get_pf1_proxy(void);
#endif
const char *dp_conf_get_vf_pattern(void);
int dp_conf_get_dhcp_mtu(void);
int dp_conf_get_wcmp_perc(void);
Expand Down
14 changes: 1 addition & 13 deletions src/dp_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,9 @@ static struct dp_conf_virtual_services virtual_services = {0};
#endif

#ifdef ENABLE_PF1_PROXY
static char dp_conf_pf1_proxy[IF_NAMESIZE] = {0};

const char *dp_conf_get_pf1_proxy(void)
{
return dp_conf_pf1_proxy;
}

bool dp_conf_is_pf1_proxy_enabled(void)
{
return *dp_conf_pf1_proxy;
return *pf1_proxy;
}
#endif

Expand Down Expand Up @@ -286,11 +279,6 @@ static int parse_line(char *line, int lineno)
if (!strcmp(key, "a-pf1"))
return dp_argparse_string(value, eal_a_pf1, sizeof(eal_a_pf1));

#ifdef ENABLE_PF1_PROXY
if (!strcmp(key, "pf1-proxy"))
return dp_argparse_string(value, dp_conf_pf1_proxy, sizeof(dp_conf_pf1_proxy));
#endif

// Otherwise support all long options
if (!longopt) {
DP_EARLY_ERR("Config file: unknown key '%s'", key);
Expand Down
27 changes: 26 additions & 1 deletion src/dp_conf_opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ enum {
_OPT_SHOPT_MAX = 255,
OPT_PF0,
OPT_PF1,
#ifdef ENABLE_PF1_PROXY
OPT_PF1_PROXY,
#endif
OPT_IPV6,
OPT_VF_PATTERN,
OPT_DHCP_MTU,
Expand Down Expand Up @@ -56,6 +59,9 @@ static const struct option dp_conf_longopts[] = {
{ "version", 0, 0, OPT_VERSION },
{ "pf0", 1, 0, OPT_PF0 },
{ "pf1", 1, 0, OPT_PF1 },
#ifdef ENABLE_PF1_PROXY
{ "pf1-proxy", 1, 0, OPT_PF1_PROXY },
#endif
{ "ipv6", 1, 0, OPT_IPV6 },
{ "vf-pattern", 1, 0, OPT_VF_PATTERN },
{ "dhcp-mtu", 1, 0, OPT_DHCP_MTU },
Expand Down Expand Up @@ -105,6 +111,9 @@ static const char *log_format_choices[] = {

static char pf0_name[IF_NAMESIZE];
static char pf1_name[IF_NAMESIZE];
#ifdef ENABLE_PF1_PROXY
static char pf1_proxy[IF_NAMESIZE];
#endif
static char vf_pattern[IF_NAMESIZE];
static int dhcp_mtu = 1500;
static int wcmp_perc = 100;
Expand Down Expand Up @@ -134,6 +143,13 @@ const char *dp_conf_get_pf1_name(void)
return pf1_name;
}

#ifdef ENABLE_PF1_PROXY
const char *dp_conf_get_pf1_proxy(void)
{
return pf1_proxy;
}

#endif
const char *dp_conf_get_vf_pattern(void)
{
return vf_pattern;
Expand Down Expand Up @@ -201,13 +217,15 @@ int dp_conf_get_flow_timeout(void)
{
return flow_timeout;
}
#endif

#endif
bool dp_conf_is_multiport_eswitch(void)
{
return multiport_eswitch;
}



/* These functions need to be implemented by the user of this generated code */
static void dp_argparse_version(void);
static int dp_argparse_opt_ipv6(const char *arg);
Expand All @@ -228,6 +246,9 @@ static inline void dp_argparse_help(const char *progname, FILE *outfile)
" -v, --version display version and exit\n"
" --pf0=IFNAME first physical interface (e.g. eth0)\n"
" --pf1=IFNAME second physical interface (e.g. eth1)\n"
#ifdef ENABLE_PF1_PROXY
" --pf1-proxy=IFNAME VF representor to use as a proxy for pf1 packets\n"
#endif
" --ipv6=ADDR6 IPv6 underlay address\n"
" --vf-pattern=PATTERN virtual interface name pattern (e.g. 'eth1vf')\n"
" --dhcp-mtu=SIZE set the mtu field in DHCP responses (68 - 1500)\n"
Expand Down Expand Up @@ -266,6 +287,10 @@ static int dp_conf_parse_arg(int opt, const char *arg)
return dp_argparse_string(arg, pf0_name, ARRAY_SIZE(pf0_name));
case OPT_PF1:
return dp_argparse_string(arg, pf1_name, ARRAY_SIZE(pf1_name));
#ifdef ENABLE_PF1_PROXY
case OPT_PF1_PROXY:
return dp_argparse_string(arg, pf1_proxy, ARRAY_SIZE(pf1_proxy));
#endif
case OPT_IPV6:
return dp_argparse_opt_ipv6(arg);
case OPT_VF_PATTERN:
Expand Down

0 comments on commit 6411090

Please sign in to comment.