Skip to content

Commit

Permalink
Fix -W option for pppoe-discovery utility (#157)
Browse files Browse the repository at this point in the history
pppoe-discovery's -W option is totally broken. pppoe-discovery currently
expects that Host-Unique attribute equals to its own process pid if set.

This patch fixes parsing received PPPoE PADO packets when -W option is set.
Same implementation is in pppd pppoe plugin.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  • Loading branch information
pali committed Aug 7, 2020
1 parent 115c419 commit 677aa53
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions pppd/plugins/rp-pppoe/pppoe-discovery.c
Expand Up @@ -328,14 +328,10 @@ void
parseForHostUniq(UINT16_t type, UINT16_t len, unsigned char *data,
void *extra)
{
int *val = (int *) extra;
if (type == TAG_HOST_UNIQ && len == sizeof(pid_t)) {
pid_t tmp;
memcpy(&tmp, data, len);
if (tmp == getpid()) {
*val = 1;
}
}
PPPoETag *tag = extra;

if (type == TAG_HOST_UNIQ && len == ntohs(tag->length))
tag->length = memcmp(data, tag->payload, len);
}

/**********************************************************************
Expand All @@ -352,16 +348,16 @@ parseForHostUniq(UINT16_t type, UINT16_t len, unsigned char *data,
int
packetIsForMe(PPPoEConnection *conn, PPPoEPacket *packet)
{
int forMe = 0;
PPPoETag hostUniq = conn->hostUniq;

/* If packet is not directed to our MAC address, forget it */
if (memcmp(packet->ethHdr.h_dest, conn->myEth, ETH_ALEN)) return 0;

/* If we're not using the Host-Unique tag, then accept the packet */
if (!conn->hostUniq.length) return 1;

parsePacket(packet, parseForHostUniq, &forMe);
return forMe;
parsePacket(packet, parseForHostUniq, &hostUniq);
return !hostUniq.length;
}

/**********************************************************************
Expand Down

0 comments on commit 677aa53

Please sign in to comment.