Skip to content

Commit

Permalink
Fix GRE de-tunneling
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanNardi committed Feb 14, 2024
1 parent f047e0c commit 22d2c6b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pl7m.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ static int dissect_l4(struct m_pkt *p)
return -1;
}
/* Check version. 0 = GRE, 1 = ENHANCED GRE (used for PPTP) */
if((gre_h->version != 0 && gre_h->version != 1) ||
(gre_h->version == 1 && ntohs(gre_h->protocol) != 0x880b)) {
if ((gre_h->version != 0 && gre_h->version != 1) ||
(gre_h->version == 1 && ntohs(gre_h->protocol) != 0x880b)) {
derr("Unexpected gre version %d\n", gre_h->version);
return -1;
}
Expand All @@ -627,12 +627,16 @@ static int dissect_l4(struct m_pkt *p)
return -1;
}

if(gre_h->version == 0) {
if (gre_h->version == 0) {
p->l3_proto = ntohs(gre_h->protocol);
if(p->l3_proto == 0 && l4_hdr_len == p->l4_length) {
if (p->l3_proto == 0 && l4_hdr_len == p->l4_length) {
derr("GRE keepalive\n");
return -1;
}
if (p->l3_proto != ETH_P_IP && p->l3_proto != ETH_P_IPV6) {
derr("Invalid L3 after GRE: 0x%x\n", p->l3_proto);
return -1;
}
} else {
ppp_h = &data[l4_hdr_len];

Expand Down

0 comments on commit 22d2c6b

Please sign in to comment.