shithub: riscv

Download patch

ref: 4885c75526f91ff9eb245b32a63512e2e67b3038
parent: 88e054ffdfed8fd229b00d4f6311aefdb769cf0d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Mar 6 20:25:11 EST 2019

devip: ignore icmp advise about laggard fragments

icmp has to advise protocols about the first
fragment only. all other fragments should be
ignored.

--- a/sys/src/9/ip/icmp.c
+++ b/sys/src/9/ip/icmp.c
@@ -401,10 +401,12 @@
 			goto raise;
 		}
 		p = (Icmp *)bp->rp;
-		pr = Fsrcvpcolx(icmp->f, p->proto);
-		if(pr != nil && pr->advise != nil) {
-			(*pr->advise)(pr, bp, msg);
-			return;
+		if((nhgets(p->frag) & ~(IP_DF|IP_MF)) == 0){
+			pr = Fsrcvpcolx(icmp->f, p->proto);
+			if(pr != nil && pr->advise != nil) {
+				(*pr->advise)(pr, bp, msg);
+				return;
+			}
 		}
 		bp->rp -= ICMP_IPSIZE+ICMP_HDRSIZE;
 		goticmpkt(icmp, bp);
--- a/sys/src/9/ip/icmp6.c
+++ b/sys/src/9/ip/icmp6.c
@@ -725,11 +725,12 @@
 				bp->rp -= IP6HDR;
 			}
 		}
-
-		pr = Fsrcvpcolx(icmp->f, p->proto);
-		if(pr != nil && pr->advise != nil) {
-			(*pr->advise)(pr, bp, msg);
-			return;
+		if(p->proto != FH){
+			pr = Fsrcvpcolx(icmp->f, p->proto);
+			if(pr != nil && pr->advise != nil) {
+				(*pr->advise)(pr, bp, msg);
+				return;
+			}
 		}
 		bp->rp -= IPICMPSZ;
 		goticmpkt6(icmp, bp, 0);