Skip to contentSkip to conversation

net: flow_dissector: do not set invalid PPP protocol

PATCH In review Boris Sukholitko 1 participant 2 messages Oct 3, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: flow_dissector: do not set invalid PPP protocol

The following flower filter fails to match non-PPP_IP{V6} packets wrapped in PPP_SES protocol:

tc filter add dev eth0 ingress protocol ppp_ses flower \
action simple sdata hi64

The reason is that proto local variable is being set even when FLOW_DISSECT_RET_OUT_BAD status is returned.

The fix is to avoid setting proto variable if the PPP protocol is unknown.

---
 net/core/flow_dissector.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/core/flow_dissector.c +1 -2
index bac0184cf3de..7d0a9f84aaf7 100644
@@ -1196,9 +1196,8 @@ bool __skb_flow_dissect(const struct net *net,
 			break;
 		}
 
-		proto = hdr->proto;
 		nhoff += PPPOE_SES_HLEN;
-		switch (proto) {
+		switch (hdr->proto) {
 		case htons(PPP_IP):
 			proto = htons(ETH_P_IP);
 			fdret = FLOW_DISSECT_RET_PROTO_AGAIN;
Signature · 1 line
2.29.2
#1 lore raw

Hi,

Please disregard, I see that the patch has been applied already.

My feeble defense is that the previous patch has "Not Applicable" state on patchwork for some reason:

https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

Thanks,
Boris.

Quoted 34 lines · Boris Sukholitko

The following flower filter fails to match non-PPP_IP{V6} packets wrapped in PPP_SES protocol:

tc filter add dev eth0 ingress protocol ppp_ses flower \
action simple sdata hi64

The reason is that proto local variable is being set even when FLOW_DISSECT_RET_OUT_BAD status is returned.

The fix is to avoid setting proto variable if the PPP protocol is unknown.

---
 net/core/flow_dissector.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/core/flow_dissector.c +1 -2
index bac0184cf3de..7d0a9f84aaf7 100644
@@ -1196,9 +1196,8 @@ bool __skb_flow_dissect(const struct net *net,
 			break;
 		}
 
-		proto = hdr->proto;
 		nhoff += PPPOE_SES_HLEN;
-		switch (proto) {
+		switch (hdr->proto) {
 		case htons(PPP_IP):
 			proto = htons(ETH_P_IP);
 			fdret = FLOW_DISSECT_RET_PROTO_AGAIN;
Signature · 1 line
2.29.2