[Midnightbsd-cvs] src [11406] sync arp with freebsd.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Fri Jul 6 21:10:08 EDT 2018
Revision: 11406
http://svnweb.midnightbsd.org/src/?rev=11406
Author: laffer1
Date: 2018-07-06 21:10:07 -0400 (Fri, 06 Jul 2018)
Log Message:
-----------
sync arp with freebsd.
Modified Paths:
--------------
trunk/usr.sbin/arp/Makefile
trunk/usr.sbin/arp/arp.4
trunk/usr.sbin/arp/arp.8
trunk/usr.sbin/arp/arp.c
Property Changed:
----------------
trunk/usr.sbin/arp/arp.4
trunk/usr.sbin/arp/arp.8
Modified: trunk/usr.sbin/arp/Makefile
===================================================================
--- trunk/usr.sbin/arp/Makefile 2018-07-07 01:09:32 UTC (rev 11405)
+++ trunk/usr.sbin/arp/Makefile 2018-07-07 01:10:07 UTC (rev 11406)
@@ -1,5 +1,6 @@
+# $MidnightBSD$
# @(#)Makefile 8.2 (Berkeley) 4/18/94
-# $MidnightBSD$
+# $FreeBSD: stable/10/usr.sbin/arp/Makefile 193984 2009-06-11 10:30:30Z des $
PROG= arp
MAN= arp.4 arp.8
Modified: trunk/usr.sbin/arp/arp.4
===================================================================
--- trunk/usr.sbin/arp/arp.4 2018-07-07 01:09:32 UTC (rev 11405)
+++ trunk/usr.sbin/arp/arp.4 2018-07-07 01:10:07 UTC (rev 11406)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1985, 1986, 1988, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)arp4.4 6.5 (Berkeley) 4/18/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/arp/arp.4 309340 2016-11-30 22:20:23Z vangyzen $
.\"
-.Dd September 3, 2012
+.Dd October 7, 2016
.Dt ARP 4
.Os
.Sh NAME
@@ -113,7 +114,7 @@
.Va net.link.ether.inet.proxyall
to 1.
.Sh MIB Variables
-The ARP protocol implements a number of configrable variables in
+The ARP protocol implements a number of configurable variables in
.Va net.link.ether.inet
branch
of the
@@ -121,45 +122,65 @@
MIB.
.Bl -tag -width "log_arp_permanent_modify"
.It Va allow_multicast
-Should the kernel install ARP entries with multicast bit set in
-the hardware address.
-Installing such entries is RFC 1812 violation, but some prorietary
-load balancing techniques require routers on network to do so.
+Install ARP entries with the multicast bit set in the hardware address.
+Installing such entries is an RFC 1812 violation, but some proprietary load
+balancing techniques require routers to do so.
Turned off by default.
+.It Va garp_rexmit_count
+Retransmit gratuitous ARP (GARP) packets when an IPv4 address is added to an
+interface.
+A GARP is always transmitted when an IPv4 address is added to an interface.
+A non-zero value causes the GARP packet to be retransmitted the stated number
+of times.
+The interval between retransmissions is doubled each time, so the
+retransmission intervals are: {1, 2, 4, 8, 16, ...} (seconds).
+The default value of zero means only the initial GARP is sent; no
+additional GARP packets are retransmitted.
+The maximum value is sixteen.
+.Pp
+The default behavior of a single GARP packet is usually sufficient.
+However, a single GARP might be dropped or lost in some circumstances.
+This is particularly harmful when a shared address is passed between cluster
+nodes.
+Neighbors on the network link might then work with a stale ARP cache and send
+packets destined for that address to the node that previously owned the
+address, which might not respond.
.It Va log_arp_movements
-Should the kernel log movements of IP addresses from one hardware
-address to an other.
+Log movements of IP addresses from one hardware address to another.
See
.Sx DIAGNOSTICS
below.
Turned on by default.
.It Va log_arp_permanent_modify
-Should the kernel log attempts of remote host on network to modify a
-permanent ARP entry.
+Log attempts by a remote host to modify a permanent ARP entry.
See
.Sx DIAGNOSTICS
below.
Turned on by default.
.It Va log_arp_wrong_iface
-Should the kernel log attempts to insert an ARP entry on an interface
-when the IP network the address belongs to is connected to an other
-interface.
+Log attempts to insert an ARP entry on an interface when the IP network to
+which the address belongs is connected to another interface.
See
.Sx DIAGNOSTICS
below.
Turned on by default.
+.It Va max_log_per_second
+Limit the number of remotely triggered logging events to a configured value per
+second.
+Default is 1 log message per second.
.It Va max_age
How long an ARP entry is held in the cache until it needs to be refreshed.
Default is 1200 seconds.
.It Va maxhold
-How many packets hold in the per-entry output queue while the entry
+How many packets to hold in the per-entry output queue while the entry
is being resolved.
Default is one packet.
.It Va maxtries
-Number of retransmits before host is considered down and error is returned.
+Number of retransmits before a host is considered down and an error is
+returned.
Default is 5 tries.
.It Va proxyall
-Enables ARP proxying for all hosts on net.
+Enables ARP proxying.
Turned off by default.
.It Va useloopback
If an ARP entry is added for local address, force the traffic to go through
@@ -230,6 +251,6 @@
.Rs
.%A Leffler, S.J.
.%A Karels, M.J.
-.%B "Trailer Encapsulations
+.%B "Trailer Encapsulations"
.%T RFC893
.Re
Property changes on: trunk/usr.sbin/arp/arp.4
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/arp/arp.8
===================================================================
--- trunk/usr.sbin/arp/arp.8 2018-07-07 01:09:32 UTC (rev 11405)
+++ trunk/usr.sbin/arp/arp.8 2018-07-07 01:10:07 UTC (rev 11406)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)arp.8 8.1 (Berkeley) 6/6/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/arp/arp.8 246143 2013-01-31 08:55:21Z glebius $
.\"
-.Dd December 25, 2008
+.Dd January 31, 2013
.Dt ARP 8
.Os
.Sh NAME
@@ -54,12 +55,12 @@
.Fl s Ar hostname ether_addr
.Op Cm temp
.Op Cm blackhole No \&| Cm reject
-.Op Cm pub Op Cm only
+.Op Cm pub
.Nm
.Fl S Ar hostname ether_addr
.Op Cm temp
.Op Cm blackhole No \&| Cm reject
-.Op Cm pub Op Cm only
+.Op Cm pub
.Nm
.Fl f Ar filename
.Sh DESCRIPTION
@@ -140,16 +141,6 @@
in which case the interfaces on this host will be examined,
and if one of them is found to occupy the same subnet, its
Ethernet address will be used.
-If the
-.Cm only
-keyword is also specified, this will create a
-.Dq "published (proxy only)"
-entry.
-This type of entry is created automatically if
-.Nm
-detects that a routing table entry for
-.Ar hostname
-already exists.
.Pp
If the
.Cm reject
@@ -181,7 +172,7 @@
.Ar hostname ether_addr
.Op Cm temp
.Op Cm blackhole No \&| Cm reject
-.Op Cm pub Op Cm only
+.Op Cm pub
.Ed
.Pp
with argument meanings as given above.
Property changes on: trunk/usr.sbin/arp/arp.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/arp/arp.c
===================================================================
--- trunk/usr.sbin/arp/arp.c 2018-07-07 01:09:32 UTC (rev 11405)
+++ trunk/usr.sbin/arp/arp.c 2018-07-07 01:10:07 UTC (rev 11406)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1984, 1993
* The Regents of the University of California. All rights reserved.
@@ -42,13 +43,12 @@
#endif /* not lint */
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.sbin/arp/arp.c 313803 2017-02-16 09:19:29Z garga $");
/*
* arp - display, set, and delete arp table entries
*/
-
#include <sys/param.h>
#include <sys/file.h>
#include <sys/socket.h>
@@ -80,22 +80,22 @@
#include <strings.h>
#include <unistd.h>
-typedef void (action_fn)(struct sockaddr_dl *sdl,
- struct sockaddr_inarp *s_in, struct rt_msghdr *rtm);
+typedef void (action_fn)(struct sockaddr_dl *sdl, struct sockaddr_in *s_in,
+ struct rt_msghdr *rtm);
static int search(u_long addr, action_fn *action);
static action_fn print_entry;
static action_fn nuke_entry;
-static int delete(char *host, int do_proxy);
+static int delete(char *host);
static void usage(void);
static int set(int argc, char **argv);
static int get(char *host);
static int file(char *name);
static struct rt_msghdr *rtmsg(int cmd,
- struct sockaddr_inarp *dst, struct sockaddr_dl *sdl);
+ struct sockaddr_in *dst, struct sockaddr_dl *sdl);
static int get_ether_addr(in_addr_t ipaddr, struct ether_addr *hwaddr);
-static struct sockaddr_inarp *getaddr(char *host);
+static struct sockaddr_in *getaddr(char *host);
static int valid_type(int type);
static int nflag; /* no reverse dns lookups */
@@ -102,8 +102,10 @@
static char *rifname;
static time_t expire_time;
-static int flags, doing_proxy, proxy_only;
+static int flags, doing_proxy;
+struct if_nameindex *ifnameindex;
+
/* which function we're supposed to do */
#define F_GET 1
#define F_SET 2
@@ -179,7 +181,7 @@
if (argc < 2 || argc > 6)
usage();
if (func == F_REPLACE)
- (void)delete(argv[0], 0);
+ (void)delete(argv[0]);
rtn = set(argc, argv) ? 1 : 0;
break;
case F_DELETE:
@@ -188,13 +190,9 @@
usage();
search(0, nuke_entry);
} else {
- if (argc == 2 && strncmp(argv[1], "pub", 3) == 0)
- ch = SIN_PROXY;
- else if (argc == 1)
- ch = 0;
- else
+ if (argc != 1)
usage();
- rtn = delete(argv[0], ch);
+ rtn = delete(argv[0]);
}
break;
case F_FILESET:
@@ -204,6 +202,9 @@
break;
}
+ if (ifnameindex != NULL)
+ if_freenameindex(ifnameindex);
+
return (rtn);
}
@@ -246,15 +247,15 @@
}
/*
- * Given a hostname, fills up a (static) struct sockaddr_inarp with
+ * Given a hostname, fills up a (static) struct sockaddr_in with
* the address of the host and returns a pointer to the
* structure.
*/
-static struct sockaddr_inarp *
+static struct sockaddr_in *
getaddr(char *host)
{
struct hostent *hp;
- static struct sockaddr_inarp reply;
+ static struct sockaddr_in reply;
bzero(&reply, sizeof(reply));
reply.sin_len = sizeof(reply);
@@ -281,6 +282,7 @@
switch (type) {
case IFT_ETHER:
case IFT_FDDI:
+ case IFT_INFINIBAND:
case IFT_ISO88023:
case IFT_ISO88024:
case IFT_ISO88025:
@@ -298,8 +300,8 @@
static int
set(int argc, char **argv)
{
- struct sockaddr_inarp *addr;
- struct sockaddr_inarp *dst; /* what are we looking for */
+ struct sockaddr_in *addr;
+ struct sockaddr_in *dst; /* what are we looking for */
struct sockaddr_dl *sdl;
struct rt_msghdr *rtm;
struct ether_addr *ea;
@@ -316,9 +318,9 @@
dst = getaddr(host);
if (dst == NULL)
return (1);
- doing_proxy = flags = proxy_only = expire_time = 0;
+ doing_proxy = flags = expire_time = 0;
while (argc-- > 0) {
- if (strncmp(argv[0], "temp", 4) == 0) {
+ if (strcmp(argv[0], "temp") == 0) {
struct timespec tp;
int max_age;
size_t len = sizeof(max_age);
@@ -328,27 +330,33 @@
&max_age, &len, NULL, 0) != 0)
err(1, "sysctlbyname");
expire_time = tp.tv_sec + max_age;
- } else if (strncmp(argv[0], "pub", 3) == 0) {
+ } else if (strcmp(argv[0], "pub") == 0) {
flags |= RTF_ANNOUNCE;
doing_proxy = 1;
- if (argc && strncmp(argv[1], "only", 3) == 0) {
- proxy_only = 1;
+ if (argc && strcmp(argv[1], "only") == 0) {
+ /*
+ * Compatibility: in pre FreeBSD 8 times
+ * the "only" keyword used to mean that
+ * an ARP entry should be announced, but
+ * not installed into routing table.
+ */
argc--; argv++;
}
- } else if (strncmp(argv[0], "blackhole", 9) == 0) {
+ } else if (strcmp(argv[0], "blackhole") == 0) {
if (flags & RTF_REJECT) {
- printf("Choose one of blackhole or reject, not both.\n");
+ errx(1, "Choose one of blackhole or reject, "
+ "not both.");
}
flags |= RTF_BLACKHOLE;
- } else if (strncmp(argv[0], "reject", 6) == 0) {
+ } else if (strcmp(argv[0], "reject") == 0) {
if (flags & RTF_BLACKHOLE) {
- printf("Choose one of blackhole or reject, not both.\n");
+ errx(1, "Choose one of blackhole or reject, "
+ "not both.");
}
flags |= RTF_REJECT;
- } else if (strncmp(argv[0], "trail", 5) == 0) {
- /* XXX deprecated and undocumented feature */
- printf("%s: Sending trailers is no longer supported\n",
- host);
+ } else {
+ warnx("Invalid parameter '%s'", argv[0]);
+ usage();
}
argv++;
}
@@ -355,7 +363,7 @@
ea = (struct ether_addr *)LLADDR(&sdl_m);
if (doing_proxy && !strcmp(eaddr, "auto")) {
if (!get_ether_addr(dst->sin_addr.s_addr, ea)) {
- printf("no interface found for %s\n",
+ warnx("no interface found for %s",
inet_ntoa(dst->sin_addr));
return (1);
}
@@ -374,7 +382,7 @@
/*
* In the case a proxy-arp entry is being added for
- * a remote end point, the RTF_ANNOUNCE flag in the
+ * a remote end point, the RTF_ANNOUNCE flag in the
* RTM_GET command is an indication to the kernel
* routing code that the interface associated with
* the prefix route covering the local end of the
@@ -385,13 +393,13 @@
warn("%s", host);
return (1);
}
- addr = (struct sockaddr_inarp *)(rtm + 1);
+ addr = (struct sockaddr_in *)(rtm + 1);
sdl = (struct sockaddr_dl *)(SA_SIZE(addr) + (char *)addr);
if ((sdl->sdl_family != AF_LINK) ||
(rtm->rtm_flags & RTF_GATEWAY) ||
!valid_type(sdl->sdl_type)) {
- printf("cannot intuit interface index and type for %s\n", host);
+ warnx("cannot intuit interface index and type for %s", host);
return (1);
}
sdl_m.sdl_type = sdl->sdl_type;
@@ -405,7 +413,7 @@
static int
get(char *host)
{
- struct sockaddr_inarp *addr;
+ struct sockaddr_in *addr;
addr = getaddr(host);
if (addr == NULL)
@@ -425,9 +433,9 @@
* Delete an arp entry
*/
static int
-delete(char *host, int do_proxy)
+delete(char *host)
{
- struct sockaddr_inarp *addr, *dst;
+ struct sockaddr_in *addr, *dst;
struct rt_msghdr *rtm;
struct sockaddr_dl *sdl;
struct sockaddr_dl sdl_m;
@@ -456,11 +464,11 @@
warn("%s", host);
return (1);
}
- addr = (struct sockaddr_inarp *)(rtm + 1);
+ addr = (struct sockaddr_in *)(rtm + 1);
sdl = (struct sockaddr_dl *)(SA_SIZE(addr) + (char *)addr);
/*
- * With the new L2/L3 restructure, the route
+ * With the new L2/L3 restructure, the route
* returned is a prefix route. The important
* piece of information from the previous
* RTM_GET is the interface index. In the
@@ -479,7 +487,7 @@
* is a proxy-arp entry to remove.
*/
if (flags & RTF_ANNOUNCE) {
- fprintf(stderr, "delete: cannot locate %s\n",host);
+ warnx("delete: cannot locate %s", host);
return (1);
}
@@ -504,7 +512,7 @@
size_t needed;
char *lim, *buf, *next;
struct rt_msghdr *rtm;
- struct sockaddr_inarp *sin2;
+ struct sockaddr_in *sin2;
struct sockaddr_dl *sdl;
char ifname[IF_NAMESIZE];
int st, found_entry = 0;
@@ -518,7 +526,7 @@
mib[5] = RTF_LLINFO;
#else
mib[5] = 0;
-#endif
+#endif
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
err(1, "route-sysctl-estimate");
if (needed == 0) /* empty table */
@@ -538,7 +546,7 @@
lim = buf + needed;
for (next = buf; next < lim; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)next;
- sin2 = (struct sockaddr_inarp *)(rtm + 1);
+ sin2 = (struct sockaddr_in *)(rtm + 1);
sdl = (struct sockaddr_dl *)((char *)sin2 + SA_SIZE(sin2));
if (rifname && if_indextoname(sdl->sdl_index, ifname) &&
strcmp(ifname, rifname))
@@ -557,18 +565,21 @@
/*
* Display an arp entry
*/
-static char lifname[IF_NAMESIZE];
-static int64_t lifindex = -1;
static void
print_entry(struct sockaddr_dl *sdl,
- struct sockaddr_inarp *addr, struct rt_msghdr *rtm)
+ struct sockaddr_in *addr, struct rt_msghdr *rtm)
{
const char *host;
struct hostent *hp;
struct iso88025_sockaddr_dl_data *trld;
+ struct if_nameindex *p;
int seg;
+ if (ifnameindex == NULL)
+ if ((ifnameindex = if_nameindex()) == NULL)
+ err(1, "cannot retrieve interface names");
+
if (nflag == 0)
hp = gethostbyaddr((caddr_t)&(addr->sin_addr),
sizeof addr->sin_addr, AF_INET);
@@ -587,7 +598,8 @@
sdl->sdl_type == IFT_L2VLAN ||
sdl->sdl_type == IFT_BRIDGE) &&
sdl->sdl_alen == ETHER_ADDR_LEN)
- printf("%s", ether_ntoa((struct ether_addr *)LLADDR(sdl)));
+ printf("%s",
+ ether_ntoa((struct ether_addr *)LLADDR(sdl)));
else {
int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0;
@@ -595,12 +607,15 @@
}
} else
printf("(incomplete)");
- if (sdl->sdl_index != lifindex &&
- if_indextoname(sdl->sdl_index, lifname) != NULL) {
- lifindex = sdl->sdl_index;
- printf(" on %s", lifname);
- } else if (sdl->sdl_index == lifindex)
- printf(" on %s", lifname);
+
+ for (p = ifnameindex; p && ifnameindex->if_index &&
+ ifnameindex->if_name; p++) {
+ if (p->if_index == sdl->sdl_index) {
+ printf(" on %s", p->if_name);
+ break;
+ }
+ }
+
if (rtm->rtm_rmx.rmx_expire == 0)
printf(" permanent");
else {
@@ -612,44 +627,45 @@
else
printf(" expired");
}
- if (addr->sin_other & SIN_PROXY)
- printf(" published (proxy only)");
if (rtm->rtm_flags & RTF_ANNOUNCE)
printf(" published");
switch(sdl->sdl_type) {
case IFT_ETHER:
- printf(" [ethernet]");
- break;
+ printf(" [ethernet]");
+ break;
case IFT_ISO88025:
- printf(" [token-ring]");
+ printf(" [token-ring]");
trld = SDL_ISO88025(sdl);
if (trld->trld_rcf != 0) {
printf(" rt=%x", ntohs(trld->trld_rcf));
for (seg = 0;
seg < ((TR_RCF_RIFLEN(trld->trld_rcf) - 2 ) / 2);
- seg++)
+ seg++)
printf(":%x", ntohs(*(trld->trld_route[seg])));
}
break;
case IFT_FDDI:
- printf(" [fddi]");
- break;
+ printf(" [fddi]");
+ break;
case IFT_ATM:
- printf(" [atm]");
- break;
+ printf(" [atm]");
+ break;
case IFT_L2VLAN:
printf(" [vlan]");
break;
case IFT_IEEE1394:
- printf(" [firewire]");
- break;
+ printf(" [firewire]");
+ break;
case IFT_BRIDGE:
printf(" [bridge]");
break;
+ case IFT_INFINIBAND:
+ printf(" [infiniband]");
+ break;
default:
break;
- }
-
+ }
+
printf("\n");
}
@@ -659,12 +675,15 @@
*/
static void
nuke_entry(struct sockaddr_dl *sdl __unused,
- struct sockaddr_inarp *addr, struct rt_msghdr *rtm __unused)
+ struct sockaddr_in *addr, struct rt_msghdr *rtm)
{
char ip[20];
+ if (rtm->rtm_flags & RTF_PINNED)
+ return;
+
snprintf(ip, sizeof(ip), "%s", inet_ntoa(addr->sin_addr));
- (void)delete(ip, 0);
+ delete(ip);
}
static void
@@ -671,18 +690,18 @@
usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
- "usage: arp [-n] [-i interface] hostname",
- " arp [-n] [-i interface] -a",
- " arp -d hostname [pub]",
- " arp -d [-i interface] -a",
- " arp -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
- " arp -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
- " arp -f filename");
+ "usage: arp [-n] [-i interface] hostname",
+ " arp [-n] [-i interface] -a",
+ " arp -d hostname [pub]",
+ " arp -d [-i interface] -a",
+ " arp -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
+ " arp -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
+ " arp -f filename");
exit(1);
}
static struct rt_msghdr *
-rtmsg(int cmd, struct sockaddr_inarp *dst, struct sockaddr_dl *sdl)
+rtmsg(int cmd, struct sockaddr_in *dst, struct sockaddr_dl *sdl)
{
static int seq;
int rlen;
@@ -728,25 +747,20 @@
rtm->rtm_rmx.rmx_expire = expire_time;
rtm->rtm_inits = RTV_EXPIRE;
rtm->rtm_flags |= (RTF_HOST | RTF_STATIC | RTF_LLDATA);
- dst->sin_other = 0;
if (doing_proxy) {
- if (proxy_only)
- dst->sin_other = SIN_PROXY;
- else {
- rtm->rtm_addrs |= RTA_NETMASK;
- rtm->rtm_flags &= ~RTF_HOST;
- }
+ rtm->rtm_addrs |= RTA_NETMASK;
+ rtm->rtm_flags &= ~RTF_HOST;
}
/* FALLTHROUGH */
case RTM_GET:
rtm->rtm_addrs |= RTA_DST;
}
-#define NEXTADDR(w, s) \
- do { \
- if ((s) != NULL && rtm->rtm_addrs & (w)) { \
- bcopy((s), cp, sizeof(*(s))); \
- cp += SA_SIZE(s); \
- } \
+#define NEXTADDR(w, s) \
+ do { \
+ if ((s) != NULL && rtm->rtm_addrs & (w)) { \
+ bcopy((s), cp, sizeof(*(s))); \
+ cp += SA_SIZE(s); \
+ } \
} while (0)
NEXTADDR(RTA_DST, dst);
@@ -802,7 +816,7 @@
}
#define NEXTIFR(i) \
- ((struct ifreq *)((char *)&(i)->ifr_addr \
+ ((struct ifreq *)((char *)&(i)->ifr_addr \
+ MAX((i)->ifr_addr.sa_len, sizeof((i)->ifr_addr))) )
/*
@@ -823,14 +837,10 @@
if (ioctl(sock, SIOCGIFFLAGS, &ifreq) < 0)
continue;
if ((ifreq.ifr_flags &
- (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|
- IFF_LOOPBACK|IFF_NOARP))
- != (IFF_UP|IFF_BROADCAST))
+ (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|
+ IFF_LOOPBACK|IFF_NOARP)) != (IFF_UP|IFF_BROADCAST))
continue;
- /*
- * Get its netmask and check that it's on
- * the right subnet.
- */
+ /* Get its netmask and check that it's on the right subnet. */
if (ioctl(sock, SIOCGIFNETMASK, &ifreq) < 0)
continue;
mask = ((struct sockaddr_in *)
@@ -860,9 +870,8 @@
*/
dla = (struct sockaddr_dl *) &ifr->ifr_addr;
memcpy(hwaddr, LLADDR(dla), dla->sdl_alen);
- printf("using interface %s for proxy with address ",
- ifp->ifr_name);
- printf("%s\n", ether_ntoa(hwaddr));
+ printf("using interface %s for proxy with address %s\n", ifp->ifr_name,
+ ether_ntoa(hwaddr));
retval = dla->sdl_alen;
done:
close(sock);
More information about the Midnightbsd-cvs
mailing list