Commit d2081838 authored by Adam Wujek's avatar Adam Wujek 💬

time-wrs: fix VLAN handling for new kernel in wrs

--Read VLAN number from aux; network driver strips VLAN information from the
--Remove a hack from common-fun.c fro WRS, it is not needed anymore;
  even for WRS we read VLAN from aux
Signed-off-by: Adam Wujek's avatarAdam Wujek <>
parent a14ec0c0
......@@ -49,11 +49,7 @@ void pp_prepare_pointers(struct pp_instance *ppi)
ppi->tx_offset = sizeof(struct pp_vlanhdr);
/* Hack warning: with wrs we get the whole header */
ppi->rx_offset = sizeof(struct pp_vlanhdr);
ppi->rx_offset = ETH_HLEN;
ppi->rx_offset = ETH_HLEN;
ppi->tx_offset = 0;
......@@ -160,7 +160,6 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
TimeInternal *t)
struct ethhdr *hdr = pkt;
struct pp_vlanhdr *vhdr = pkt;
struct wrs_socket *s;
struct msghdr msg;
struct iovec entry;
......@@ -168,7 +167,8 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
int i;
union {
struct cmsghdr cm;
char control[1024];
char aux_buf[CMSG_SPACE(sizeof(struct tpacket_auxdata))];
char time_buf[1024];
} control;
struct cmsghdr *cmsg;
struct scm_timestamping *sts = NULL;
......@@ -239,32 +239,19 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
if (aux) {
pp_diag(ppi, frames, 1,"aux: %x proto %x\n", aux->tp_vlan_tci,
if (0) {
"PPSi error: unexpected auxiliary data\n");
errno = EINVAL;
return -1;
/* For UDP, avoid all of the following, as we don't have vlans */
if (ppi->proto == PPSI_PROTO_UDP)
goto out;
* While on PC-class ethernet driver we see the internal frame,
* our simple WR driver returns the whole frame. No aux pointer
* is there, at this point in time. So unroll vlan header.
* Ethernet driver returns internal frame. Our simple WR driver used to
* return the whole frame, but not anymore. Use aux pointer to get VLAN
if (vhdr->h_tpid == htons(0x8100)) {
int vlan = ntohs(vhdr->h_tci) & 0xfff;
if (aux) {
int vlan = aux->tp_vlan_tci & 0xfff;
/* With PROTO_VLAN, we bound to ETH_P_ALL: we got all frames */
if (vhdr->h_proto != htons(ETH_P_1588))
if (hdr->h_proto != htons(ETH_P_1588))
return -2; /* like "dropped", so no error message */
/* Also, we got the vlan, and we can discard it if not ours */
......@@ -617,6 +604,7 @@ static int wrs_enable_timestamps(struct pp_instance *ppi, int fd)
return -1;
return 0;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment