Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ bpf_open(const struct interface *ifp,
#ifdef BIOCIMMEDIATE
unsigned int flags;
#endif
#ifdef BIOCSETVLANPCP
unsigned int vlan_pcp;
#endif
#ifndef O_CLOEXEC
int fd_opts;
#endif
Expand Down Expand Up @@ -207,6 +210,14 @@ bpf_open(const struct interface *ifp,
if (ioctl(bpf->bpf_fd, BIOCSETIF, &ifr) == -1)
goto eexit;

#ifdef BIOCSETVLANPCP
if (ifp->options->vlan_pcp != -1) {
vlan_pcp = (u_int)ifp->options->vlan_pcp;
if (ioctl(bpf->bpf_fd, BIOCSETVLANPCP, &vlan_pcp) == -1)
goto eexit;
}
#endif

#ifdef BIOCIMMEDIATE
flags = 1;
if (ioctl(bpf->bpf_fd, BIOCIMMEDIATE, &flags) == -1)
Expand Down
19 changes: 19 additions & 0 deletions src/if-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <sys/types.h>

#include <arpa/inet.h>
#include <net/bpf.h>

#include <ctype.h>
#include <errno.h>
Expand Down Expand Up @@ -176,6 +177,9 @@ const struct option cf_options[] = {
{"fallback_time", required_argument, NULL, O_FALLBACK_TIME},
{"ipv4ll_time", required_argument, NULL, O_IPV4LL_TIME},
{"nosyslog", no_argument, NULL, O_NOSYSLOG},
#ifdef BIOCSETVLANPCP
{"vlan_pcp", required_argument, NULL, O_VLANPCP},
#endif
{NULL, 0, NULL, '\0'}
};

Expand Down Expand Up @@ -2571,6 +2575,16 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
logsetopts(logopts);
}
break;
#ifdef BIOCSETVLANPCP
case O_VLANPCP:
ARG_REQUIRED;
ifo->vlan_pcp =
(int)strtoi(arg, NULL, 0, 0, VLAN_PCP_MAX, &e);
if (e) {
logerrx("invalid vlan-pcp: %s", arg);
return -1;
}
#endif
default:
return 0;
}
Expand Down Expand Up @@ -2666,6 +2680,11 @@ default_config(struct dhcpcd_ctx *ctx)
TAILQ_INIT(&ifo->auth.tokens);
#endif

#ifdef BIOCSETVLANPCP
/* Disable PCP tagging */
ifo->vlan_pcp = -1;
#endif

/* Inherit some global defaults */
if (ctx->options & DHCPCD_CONFIGURE)
ifo->options |= DHCPCD_CONFIGURE;
Expand Down
8 changes: 8 additions & 0 deletions src/if-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <net/bpf.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux does not have this header, please #ifdef it.... or we could just configure the option regardless of the capability.


#include <getopt.h>
#include <limits.h>
Expand Down Expand Up @@ -190,6 +191,9 @@
#define O_VSIO O_BASE + 57
#define O_VSIO6 O_BASE + 58
#define O_NOSYSLOG O_BASE + 59
#ifdef BIOCSETVLANPCP
#define O_VLANPCP O_BASE + 60
#endif

extern const struct option cf_options[];

Expand Down Expand Up @@ -313,6 +317,10 @@ struct if_options {
#endif

struct auth auth;

#ifdef BIOCSETVLANPCP
int vlan_pcp;
#endif
};

struct if_options *read_config(struct dhcpcd_ctx *,
Expand Down
2 changes: 2 additions & 0 deletions src/if.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ typedef unsigned long ioctl_request_t;
#include "ipv6.h"
#include "route.h"

#define VLAN_PCP_MAX 7

#define EUI64_ADDR_LEN 8
#define INFINIBAND_ADDR_LEN 20

Expand Down
Loading