Skip to content

Commit

Permalink
split vnetflowid as aargument "vnetflowid"
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowman committed May 7, 2021
1 parent f5b1d00 commit 2ffadf7
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions commands.c
Expand Up @@ -520,6 +520,7 @@ struct intlist Intlist[] = {
{ "txprio", "Priority in tunnel protocol headers", CMPL0 0, 0, intmpls },
{ "rxprio", "Source used for packet priority", CMPL0 0, 0, intmpls },
{ "vnetid", "Virtual interface network identifier", CMPL0 0, 0, intvnetid },
{ "vnetflowid", "Use part of vnetid as flowid", CMPL0 0, 0, intvnetflowid },
{ "parent", "Parent interface", CMPL(i) 0, 0, intparent },
{ "patch", "Pair interface", CMPL(i) 0, 0, intpatch },
{ "keepalive", "GRE tunnel keepalive", CMPL0 0, 0, intkeepalive },
Expand Down
16 changes: 16 additions & 0 deletions conf.c
Expand Up @@ -63,6 +63,7 @@ int conf_ifaddrs(FILE *, char *, int, int);
int conf_ifaddr_dhcp(FILE *, char *, int);
void conf_ifflags(FILE *, int, char *, int, u_char);
void conf_vnetid(FILE *, int, char *);
void conf_vnetflowid(FILE *, int, char *);
void conf_parent(FILE *, int, char *);
void conf_patch(FILE *, int, char *);
void conf_brcfg(FILE *, int, struct if_nameindex *, char *);
Expand Down Expand Up @@ -539,6 +540,7 @@ void conf_interfaces(FILE *output, char *only)
conf_db_single(output, "rtadvd", NULL, ifnp->if_name);

conf_vnetid(output, ifs, ifnp->if_name);
conf_vnetflowid(output, ifs, ifnp->if_name);
conf_parent(output, ifs, ifnp->if_name);
conf_patch(output, ifs, ifnp->if_name);
conf_rdomain(output, ifs, ifnp->if_name);
Expand Down Expand Up @@ -612,6 +614,20 @@ void conf_vnetid(FILE *output, int ifs, char *ifname)
}
}

void conf_vnetflowid(FILE *output, int ifs, char *ifname)
{
struct ifreq ifr;

bzero(&ifr, sizeof(ifr));
strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);

if (ioctl(ifs, SIOCGVNETFLOWID, &ifr) == -1)
return;

if (ifr.ifr_vnetid)
fprintf(output, " vnetflowid\n");
}

void conf_patch(FILE *output, int ifs, char *ifname)
{
struct ifreq ifr;
Expand Down
1 change: 1 addition & 0 deletions externs.h
Expand Up @@ -416,6 +416,7 @@ int intparent(char *, int, int, char **);
int intpatch(char *, int, int, char **);
int intmpls(char *, int, int, char **);
int intpwe3(char *, int, int, char **);
int intvnetflowid(char *, int, int, char **);
int addaf(char *, int, int);
int removeaf(char *, int, int);
char *get_hwdaddr(char *);
Expand Down
33 changes: 33 additions & 0 deletions if.c
Expand Up @@ -2270,3 +2270,36 @@ intdesc(char *ifname, int ifs, int argc, char **argv)

return(0);
}

int
intvnetflowid(char *ifname, int ifs, int argc, char **argv)
{
int set;
struct ifreq ifr;

if (NO_ARG(argv[0])) {
set = 0;
argv++;
argc--;
} else
set = 1;

argv++;
argc--;

if (set && argc != 0) {
printf("%% vnetflowid\n");
printf("%% no vnetlowid\n");
return(0);
}

if (set)
ifr.ifr_vnetid = 1;
else
ifr.ifr_vnetid = 0;
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(ifs, SIOCSVNETFLOWID, &ifr) < 0)
printf("%% intvnetflowid: SIOCSVNETFLOWID: %s\n", strerror(errno));

return(0);
}

0 comments on commit 2ffadf7

Please sign in to comment.