summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-09-01 15:08:40 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2018-09-01 15:08:40 +0200
commit5a2c3580fc1b0ca53deb62c1b3e0391ce3895dd8 (patch)
tree56eb00039c3d4774bdc2f0a15099ae4d51a6c9bc
parent4e61bc282c2869ae8442e356ffd2da3a3818dd51 (diff)
downloadplan9front-5a2c3580fc1b0ca53deb62c1b3e0391ce3895dd8.tar.xz
ip/dhcpd: bring back interface address for arpenter()
the arp table is per interface, so it is possible to have the same netwrok on multiple physical interfaces, tho with different source ip address. one example would be a ethernet and a wlan interface. the mac addresses on these mediums can differ (arp proxying taking place). so provide our source address on the interface we received the request on. the previous change used the ifcaddr; which is correct; but due to a oversight in the kernel, had to match the ip of the arp entry. source address will always work.
-rw-r--r--sys/src/cmd/ip/dhcpd/dhcpd.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/sys/src/cmd/ip/dhcpd/dhcpd.c b/sys/src/cmd/ip/dhcpd/dhcpd.c
index f675bc4d5..f0b24edef 100644
--- a/sys/src/cmd/ip/dhcpd/dhcpd.c
+++ b/sys/src/cmd/ip/dhcpd/dhcpd.c
@@ -165,7 +165,7 @@ char *optname[256] =
void addropt(Req*, int, uchar*);
void addrsopt(Req*, int, uchar**, int);
-void arpenter(uchar*, uchar*);
+void arpenter(uchar*, uchar*, uchar*);
void bootp(Req*);
void byteopt(Req*, int, uchar);
void dhcp(Req*);
@@ -746,7 +746,7 @@ sendoffer(Req *rp, uchar *ip, int offer)
} else {
ipmove(up->raddr, ip);
if(bp->htype == 1)
- arpenter(up->raddr, bp->chaddr);
+ arpenter(up->raddr, bp->chaddr, up->laddr);
hnputs(up->rport, 68);
}
@@ -805,7 +805,7 @@ sendack(Req *rp, uchar *ip, int offer, int sendlease)
} else {
ipmove(up->raddr, ip);
if(bp->htype == 1)
- arpenter(up->raddr, bp->chaddr);
+ arpenter(up->raddr, bp->chaddr, up->laddr);
hnputs(up->rport, 68);
}
@@ -993,7 +993,7 @@ bootp(Req *rp)
} else {
v4tov6(up->raddr, bp->yiaddr);
if(bp->htype == 1)
- arpenter(up->raddr, bp->chaddr);
+ arpenter(up->raddr, bp->chaddr, up->laddr);
hnputs(up->rport, 68);
}
@@ -1576,19 +1576,20 @@ hexopt(Req *rp, int t, char *str)
}
void
-arpenter(uchar *ip, uchar *ether)
+arpenter(uchar *ip, uchar *mac, uchar *src)
{
- int f;
char buf[256];
+ int fd, n;
- sprint(buf, "%s/arp", net);
- f = open(buf, OWRITE);
- if(f < 0){
- syslog(debug, blog, "open %s: %r", buf);
+ snprint(buf, sizeof buf, "%s/arp", net);
+ if((fd = open(buf, OWRITE)) < 0){
+ warning("couldn't open %s: %r", buf);
return;
}
- fprint(f, "add ether %I %E", ip, ether);
- close(f);
+ n = snprint(buf, sizeof buf, "add ether %I %E %I\n", ip, mac, src);
+ if(write(fd, buf, n) != n)
+ warning("arpenter: %s: %r", buf);
+ close(fd);
}
char *dhcpmsgname[] =