aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/arp/arp.c19
-rw-r--r--usr.sbin/ndp/ndp.c3
-rw-r--r--usr.sbin/rarpd/rarpd.c6
-rw-r--r--usr.sbin/route6d/route6d.c16
4 files changed, 24 insertions, 20 deletions
diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c
index a7e1bc830e4b..fb909142e0de 100644
--- a/usr.sbin/arp/arp.c
+++ b/usr.sbin/arp/arp.c
@@ -404,7 +404,7 @@ set(int argc, char **argv)
* the prefix route covering the local end of the
* PPP link should be returned, on which ARP applies.
*/
- rtm = rtmsg(RTM_GET, dst, &sdl_m);
+ rtm = rtmsg(RTM_GET, dst, NULL);
if (rtm == NULL) {
xo_warn("%s", host);
return (1);
@@ -466,7 +466,6 @@ delete(char *host)
struct sockaddr_in *addr, *dst;
struct rt_msghdr *rtm;
struct sockaddr_dl *sdl;
- struct sockaddr_dl sdl_m;
dst = getaddr(host);
if (dst == NULL)
@@ -477,17 +476,8 @@ delete(char *host)
*/
flags &= ~RTF_ANNOUNCE;
- /*
- * setup the data structure to notify the kernel
- * it is the ARP entry the RTM_GET is interested
- * in
- */
- bzero(&sdl_m, sizeof(sdl_m));
- sdl_m.sdl_len = sizeof(sdl_m);
- sdl_m.sdl_family = AF_LINK;
-
for (;;) { /* try twice */
- rtm = rtmsg(RTM_GET, dst, &sdl_m);
+ rtm = rtmsg(RTM_GET, dst, NULL);
if (rtm == NULL) {
xo_warn("%s", host);
return (1);
@@ -511,7 +501,7 @@ delete(char *host)
}
/*
- * Regualar entry delete failed, now check if there
+ * Regular entry delete failed, now check if there
* is a proxy-arp entry to remove.
*/
if (flags & RTF_ANNOUNCE) {
@@ -815,7 +805,8 @@ doit:
}
do {
l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
- } while (l > 0 && (rtm->rtm_seq != seq || rtm->rtm_pid != pid));
+ } while (l > 0 && (rtm->rtm_type != cmd || rtm->rtm_seq != seq ||
+ rtm->rtm_pid != pid));
if (l < 0)
xo_warn("read from routing socket");
return (rtm);
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index 8a82efc73d17..79aef78b0a64 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -888,7 +888,8 @@ doit:
}
do {
l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
- } while (l > 0 && (rtm->rtm_seq != seq || rtm->rtm_pid != pid));
+ } while (l > 0 && (rtm->rtm_type != cmd || rtm->rtm_seq != seq ||
+ rtm->rtm_pid != pid));
if (l < 0)
(void) fprintf(stderr, "ndp: read from routing socket: %s\n",
strerror(errno));
diff --git a/usr.sbin/rarpd/rarpd.c b/usr.sbin/rarpd/rarpd.c
index 2bb333c553c8..00f23f8fa28b 100644
--- a/usr.sbin/rarpd/rarpd.c
+++ b/usr.sbin/rarpd/rarpd.c
@@ -755,7 +755,8 @@ update_arptab(u_char *ep, in_addr_t ipaddr)
}
do {
cc = read(r, rt, sizeof(rtmsg));
- } while (cc > 0 && (rt->rtm_seq != seq || rt->rtm_pid != pid));
+ } while (cc > 0 && (rt->rtm_type != RTM_GET || rt->rtm_seq != seq ||
+ rt->rtm_pid != pid));
if (cc == -1) {
logmsg(LOG_ERR, "rtmsg get read: %m");
close(r);
@@ -803,7 +804,8 @@ update_arptab(u_char *ep, in_addr_t ipaddr)
}
do {
cc = read(r, rt, sizeof(rtmsg));
- } while (cc > 0 && (rt->rtm_seq != seq || rt->rtm_pid != pid));
+ } while (cc > 0 && (rt->rtm_type != RTM_ADD || rt->rtm_seq != seq ||
+ rt->rtm_pid != pid));
close(r);
if (cc == -1) {
logmsg(LOG_ERR, "rtmsg add read: %m");
diff --git a/usr.sbin/route6d/route6d.c b/usr.sbin/route6d/route6d.c
index e746acf5f575..90fba9bc048b 100644
--- a/usr.sbin/route6d/route6d.c
+++ b/usr.sbin/route6d/route6d.c
@@ -1768,14 +1768,23 @@ rtrecv(void)
break;
default:
rtm = (struct rt_msghdr *)(void *)p;
- addrs = rtm->rtm_addrs;
- q = (char *)(rtm + 1);
if (rtm->rtm_version != RTM_VERSION) {
trace(1, "unexpected rtmsg version %d "
"(should be %d)\n",
rtm->rtm_version, RTM_VERSION);
continue;
}
+ /*
+ * Only messages that use the struct rt_msghdr
+ * format are allowed beyond this point.
+ */
+ if (rtm->rtm_type > RTM_RESOLVE) {
+ trace(1, "rtmsg type %d ignored\n",
+ rtm->rtm_type);
+ continue;
+ }
+ addrs = rtm->rtm_addrs;
+ q = (char *)(rtm + 1);
if (rtm->rtm_pid == pid) {
#if 0
trace(1, "rtmsg looped back to me, ignored\n");
@@ -2973,7 +2982,8 @@ getroute(struct netinfo6 *np, struct in6_addr *gw)
exit(1);
}
rtm = (struct rt_msghdr *)(void *)buf;
- } while (rtm->rtm_seq != myseq || rtm->rtm_pid != pid);
+ } while (rtm->rtm_type != RTM_GET || rtm->rtm_seq != myseq ||
+ rtm->rtm_pid != pid);
sin6 = (struct sockaddr_in6 *)(void *)&buf[sizeof(struct rt_msghdr)];
if (rtm->rtm_addrs & RTA_DST) {
sin6 = (struct sockaddr_in6 *)(void *)