summaryrefslogtreecommitdiff
path: root/sys/src/9/ip/icmp.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2022-12-13 22:23:01 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2022-12-13 22:23:01 +0000
commit074b691f16faba137ab9cb48471fc3160b33da40 (patch)
tree1fd8f9a2342185717d541655fc74347b5f570f56 /sys/src/9/ip/icmp.c
parent5f42bde60275e9a0c3d317ee1e052e1aefdcdb19 (diff)
devip: tcpmssclamp() to minimum of source and destination interface MTU
We used to only clamp to the MTU of the destination interface, but this is wrong. We have to clamp to the minimum of both source and destination. For this, we change the gating argument type of ipoput4() and ipoput6() from int to Ipifc* to pass the source interface.
Diffstat (limited to 'sys/src/9/ip/icmp.c')
-rw-r--r--sys/src/9/ip/icmp.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/sys/src/9/ip/icmp.c b/sys/src/9/ip/icmp.c
index 526540af3..c4168605b 100644
--- a/sys/src/9/ip/icmp.c
+++ b/sys/src/9/ip/icmp.c
@@ -185,7 +185,7 @@ icmpkick(void *x, Block *bp)
memset(p->cksum, 0, sizeof(p->cksum));
hnputs(p->cksum, ptclcsum(bp, ICMP_IPSIZE, blocklen(bp) - ICMP_IPSIZE));
ipriv->stats[OutMsgs]++;
- ipoput4(c->p->f, bp, 0, c->ttl, c->tos, nil);
+ ipoput4(c->p->f, bp, nil, c->ttl, c->tos, nil);
}
static int
@@ -240,7 +240,7 @@ icmpttlexceeded(Fs *f, Ipifc *ifc, Block *bp)
hnputs(np->seq, 0);
memset(np->cksum, 0, sizeof(np->cksum));
hnputs(np->cksum, ptclcsum(nbp, ICMP_IPSIZE, blocklen(nbp) - ICMP_IPSIZE));
- ipoput4(f, nbp, 0, MAXTTL, DFLTTOS, nil);
+ ipoput4(f, nbp, nil, MAXTTL, DFLTTOS, nil);
}
static void
@@ -280,7 +280,7 @@ icmpunreachable(Fs *f, Ipifc *ifc, Block *bp, int code, int seq)
hnputs(np->seq, seq);
memset(np->cksum, 0, sizeof(np->cksum));
hnputs(np->cksum, ptclcsum(nbp, ICMP_IPSIZE, blocklen(nbp) - ICMP_IPSIZE));
- ipoput4(f, nbp, 0, MAXTTL, DFLTTOS, nil);
+ ipoput4(f, nbp, nil, MAXTTL, DFLTTOS, nil);
}
void
@@ -302,7 +302,7 @@ icmpcantfrag(Fs *f, Block *bp, int mtu)
}
static void
-goticmpkt(Proto *icmp, Block *bp)
+goticmpkt(Proto *icmp, Block *bp, Ipifc *ifc)
{
uchar dst[IPaddrlen], src[IPaddrlen];
ushort recid;
@@ -331,7 +331,7 @@ goticmpkt(Proto *icmp, Block *bp)
q = nil;
qunlock(icmp);
- ipoput4(icmp->f, bp, 1, hop - 1, p->tos, q);
+ ipoput4(icmp->f, bp, ifc, hop - 1, p->tos, q);
return;
}
for(c = icmp->conv; (s = *c) != nil; c++){
@@ -386,7 +386,7 @@ static char *unreachcode[] =
};
static void
-icmpiput(Proto *icmp, Ipifc*, Block *bp)
+icmpiput(Proto *icmp, Ipifc *ifc, Block *bp)
{
int n;
Icmp *p;
@@ -426,14 +426,14 @@ icmpiput(Proto *icmp, Ipifc*, Block *bp)
if(r == nil)
goto raise;
ipriv->out[EchoReply]++;
- ipoput4(icmp->f, r, 0, MAXTTL, DFLTTOS, nil);
+ ipoput4(icmp->f, r, nil, MAXTTL, DFLTTOS, nil);
break;
case TimeExceed:
if(p->code == 0){
snprint(msg = m2, sizeof m2, "ttl exceeded at %V", p->src);
goto Advise;
}
- goticmpkt(icmp, bp);
+ goticmpkt(icmp, bp, ifc);
break;
case Unreachable:
if(p->code >= nelem(unreachcode)) {
@@ -455,14 +455,14 @@ icmpiput(Proto *icmp, Ipifc*, Block *bp)
pr = Fsrcvpcolx(icmp->f, p->proto);
if(pr != nil && pr->advise != nil) {
netlog(icmp->f, Logicmp, "advising %s!%V -> %V: %s\n", pr->name, p->src, p->dst, msg);
- (*pr->advise)(pr, bp, msg);
+ (*pr->advise)(pr, bp, ifc, msg);
return;
}
}
bp->rp -= ICMP_IPSIZE+ICMP_HDRSIZE;
/* wet floor */
default:
- goticmpkt(icmp, bp);
+ goticmpkt(icmp, bp, ifc);
break;
}
return;
@@ -479,7 +479,7 @@ raise:
* and send the advice to ip4.
*/
void
-icmpproxyadvice(Fs *f, Block *bp, uchar *ip4)
+icmpproxyadvice(Fs *f, Block *bp, Ipifc *ifc, uchar *ip4)
{
Icmp *p;
int hop;
@@ -509,14 +509,14 @@ icmpproxyadvice(Fs *f, Block *bp, uchar *ip4)
memset(p->cksum, 0, sizeof(p->cksum));
hnputs(p->cksum, ptclcsum(bp, ICMP_IPSIZE, blocklen(bp) - ICMP_IPSIZE));
- ipoput4(f, bp, 1, hop - 1, p->tos, nil);
+ ipoput4(f, bp, ifc, hop - 1, p->tos, nil);
return;
drop:
freeblist(bp);
}
static void
-icmpadvise(Proto *icmp, Block *bp, char *msg)
+icmpadvise(Proto *icmp, Block *bp, Ipifc *ifc, char *msg)
{
uchar dst[IPaddrlen], src[IPaddrlen];
ushort recid;
@@ -543,7 +543,7 @@ icmpadvise(Proto *icmp, Block *bp, char *msg)
hnputs_csum(p->icmpid, q->forward.rport, p->cksum);
qunlock(icmp);
- icmpproxyadvice(icmp->f, bp, p->src);
+ icmpproxyadvice(icmp->f, bp, ifc, p->src);
return;
}
for(c = icmp->conv; (s = *c) != nil; c++){