From 078139041154efcdcccec91988220aaa312f26fe Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sat, 14 Mar 2009 11:41:35 +0800 Subject: [PATCH] Add static ARP support. Obtained-from: FreeBSD --- sbin/ifconfig/ifconfig.8 | 8 ++++++++ sbin/ifconfig/ifconfig.c | 2 -- sys/net/if.h | 1 + sys/netinet/if_ether.c | 6 ++++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 59399c99c4..0e39068d12 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -229,6 +229,14 @@ addresses and .It Fl arp Disable the use of the Address Resolution Protocol .Pq Xr arp 4 . +.It Cm staticarp +If the Address Resolution Protocol is enabled, +the host will only reply to requests for its addresses, +and will never send any requests. +.It Fl staticarp +If the Address Resolution Protocol is enabled, +the host will perform normally, +sending out requests and listening for replies. .It Cm broadcast (Inet only.) Specify the address to use to represent broadcasts to the diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 6a8ebcff97..e04875cf65 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1072,10 +1072,8 @@ static struct cmd basic_cmds[] = { DEF_CMD("-link2", -IFF_LINK2, setifflags), DEF_CMD("monitor", IFF_MONITOR, setifflags), DEF_CMD("-monitor", -IFF_MONITOR, setifflags), -#ifdef notyet DEF_CMD("staticarp", IFF_STATICARP, setifflags), DEF_CMD("-staticarp", -IFF_STATICARP, setifflags), -#endif DEF_CMD("polling", IFF_POLLING, setifflags), DEF_CMD("-polling", -IFF_POLLING, setifflags), DEF_CMD("rxcsum", IFCAP_RXCSUM, setifcap), diff --git a/sys/net/if.h b/sys/net/if.h index 4f2af95e88..bad78f7ebd 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -137,6 +137,7 @@ struct if_data { #define IFF_POLLING 0x10000 /* Interface is in polling mode. */ #define IFF_PPROMISC 0x20000 /* user-requested promisc mode */ #define IFF_MONITOR 0x40000 /* user-requested monitor mode */ +#define IFF_STATICARP 0x80000 /* static ARP */ /* flags set internally only: */ #define IFF_CANTCHANGE \ diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index bfb5665505..ec2ffa8ad2 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -509,12 +509,12 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m, return 1; } /* - * If ARP is disabled on this interface, stop. + * If ARP is disabled or static on this interface, stop. * XXX * Probably should not allocate empty llinfo struct if we are * not going to be sending out an arp request. */ - if (ifp->if_flags & IFF_NOARP) { + if (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) { m_freem(m); return (0); } @@ -893,6 +893,8 @@ match: itaddr = myaddr; goto reply; } + if (ifp->if_flags & IFF_STATICARP) + goto reply; #ifdef SMP netmsg_init(&msg.netmsg, &curthread->td_msgport, 0, arp_update_msghandler); -- 2.41.0