summaryrefslogtreecommitdiff
path: root/fw/src/ether.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/src/ether.c')
-rw-r--r--fw/src/ether.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/fw/src/ether.c b/fw/src/ether.c
index dd20971..d77143a 100644
--- a/fw/src/ether.c
+++ b/fw/src/ether.c
@@ -38,7 +38,6 @@ enum
Arplen = 28,
Eminlen = 60, /* ethernet minimum frame, devether enforces it */
- Maxframe = Ehdrlen + 16*1024,
Arpreq = 1,
Arpreply = 2,
@@ -321,19 +320,21 @@ etherisip(uchar *f, int n)
* its ethernet address yet we ask and drop this one; the sender will
* try again, which is what every other stack does too.
*/
+/*
+ * Build a frame around an IP packet and send it. The frame buffer
+ * belongs to the caller: 64K of it on the stack once overran a proc
+ * stack and corrupted the data segment, and sizing it here instead
+ * only moves the question of how big is big enough away from the one
+ * place - etherout - that knows how much it can read.
+ */
int
-etherwriteip(uchar *p, int n, uchar *mask)
+etherwriteip(uchar *f, int nf, uchar *p, int n, uchar *mask)
{
- /*
- * On a proc stack, which libthread keeps small: 64K here
- * overran it and corrupted the data segment. pktmedium's maxtu
- * is 4096, so this is already generous.
- */
- uchar f[Maxframe], dst[IPaddrlen], hop[IPaddrlen];
+ uchar dst[IPaddrlen], hop[IPaddrlen];
uchar net[IPaddrlen], ournet[IPaddrlen], mac[Eaddrlen];
int type, len;
- if(n < 20 || n > Maxframe - Ehdrlen)
+ if(n < 20 || nf < Eminlen || n + Ehdrlen > nf)
return -1;
switch(p[0] >> 4){
case 4:
@@ -369,10 +370,13 @@ etherwriteip(uchar *p, int n, uchar *mask)
if(!isv4(hop)){
static int said;
- if(!said++)
+ if(!said++){
fprint(2, "fw: cannot resolve %I: "
"IPv6 neighbour discovery is not implemented, "
"so v6 unicast is dropped\n", hop);
+ syslog(0, "fw", "dropping v6 unicast to %I: "
+ "no neighbour discovery", hop);
+ }
return -1;
}
if(etherdebug)