Update to FreeBSD 9.2

This commit is contained in:
Sebastian Huber
2013-11-06 16:20:21 +01:00
parent ce96623934
commit 66659ff1ad
596 changed files with 50781 additions and 19477 deletions

View File

@@ -206,9 +206,16 @@ void
#endif /* __rtems__ */
inet_ctor(void)
{
#ifndef RESCUE
if (!feature_present("inet"))
return;
#endif
#ifdef __rtems__
memset(&in_addreq, 0, sizeof(in_addreq));
memset(&in_ridreq, 0, sizeof(in_ridreq));
#endif /* __rtems__ */
af_register(&af_inet);
}

View File

@@ -72,6 +72,7 @@ static int explicit_prefix = 0;
extern void setnd6flags(const char *, int, int, const struct afswtch *);
extern void setnd6defif(const char *, int, int, const struct afswtch *);
extern void nd6_status(int);
static char addr_buf[MAXHOSTNAMELEN *2 + 1]; /*for getnameinfo()*/
@@ -510,6 +511,8 @@ static struct cmd inet6_cmds[] = {
DEF_CMD("-autoconf", -IN6_IFF_AUTOCONF, setip6flags),
DEF_CMD("accept_rtadv", ND6_IFF_ACCEPT_RTADV, setnd6flags),
DEF_CMD("-accept_rtadv",-ND6_IFF_ACCEPT_RTADV, setnd6flags),
DEF_CMD("no_radr", ND6_IFF_NO_RADR, setnd6flags),
DEF_CMD("-no_radr", -ND6_IFF_NO_RADR, setnd6flags),
DEF_CMD("defaultif", 1, setnd6defif),
DEF_CMD("-defaultif", -1, setnd6defif),
DEF_CMD("ifdisabled", ND6_IFF_IFDISABLED, setnd6flags),
@@ -518,6 +521,10 @@ static struct cmd inet6_cmds[] = {
DEF_CMD("-nud", -ND6_IFF_PERFORMNUD, setnd6flags),
DEF_CMD("prefer_source",ND6_IFF_PREFER_SOURCE, setnd6flags),
DEF_CMD("-prefer_source",-ND6_IFF_PREFER_SOURCE,setnd6flags),
DEF_CMD("auto_linklocal",ND6_IFF_AUTO_LINKLOCAL,setnd6flags),
DEF_CMD("-auto_linklocal",-ND6_IFF_AUTO_LINKLOCAL,setnd6flags),
DEF_CMD("no_prefer_iface",ND6_IFF_NO_PREFER_IFACE,setnd6flags),
DEF_CMD("-no_prefer_iface",-ND6_IFF_NO_PREFER_IFACE,setnd6flags),
DEF_CMD_ARG("pltime", setip6pltime),
DEF_CMD_ARG("vltime", setip6vltime),
DEF_CMD("eui64", 0, setip6eui64),
@@ -529,6 +536,7 @@ static struct afswtch af_inet6 = {
.af_status = in6_status,
.af_getaddr = in6_getaddr,
.af_getprefix = in6_getprefix,
.af_other_status = nd6_status,
.af_postproc = in6_postproc,
.af_status_tunnel = in6_status_tunnel,
.af_settunnel = in6_set_tunnel,
@@ -564,6 +572,11 @@ inet6_ctor(void)
#define N(a) (sizeof(a) / sizeof(a[0]))
size_t i;
#ifndef RESCUE
if (!feature_present("inet6"))
return;
#endif
for (i = 0; i < N(inet6_cmds); i++)
cmd_register(&inet6_cmds[i]);
af_register(&af_inet6);

View File

@@ -60,11 +60,12 @@ static const char rcsid[] =
#define MAX_SYSCTL_TRY 5
#define ND6BITS "\020\001PERFORMNUD\002ACCEPT_RTADV\003PREFER_SOURCE" \
"\004IFDISABLED\005DONT_SET_IFROUTE\006AUTO_LINKLOCAL" \
"\020DEFAULTIF"
"\007NO_RADR\010NO_PREFER_IFACE\020DEFAULTIF"
static int isnd6defif(int);
void setnd6flags(const char *, int, int, const struct afswtch *);
void setnd6defif(const char *, int, int, const struct afswtch *);
void nd6_status(int);
void
setnd6flags(const char *dummyaddr __unused,
@@ -138,74 +139,25 @@ isnd6defif(int s)
return (ndifreq.ifindex == ifindex);
}
static void
void
nd6_status(int s)
{
struct in6_ndireq nd;
struct rt_msghdr *rtm;
size_t needed;
char *buf, *next;
int mib[6], ntry;
int s6;
int error;
int isinet6, isdefif;
/* Check if the interface has at least one IPv6 address. */
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
mib[2] = 0;
mib[3] = AF_INET6;
mib[4] = NET_RT_IFLIST;
mib[5] = if_nametoindex(ifr.ifr_name);
/* Try to prevent a race between two sysctls. */
ntry = 0;
do {
error = sysctl(mib, 6, NULL, &needed, NULL, 0);
if (error) {
warn("sysctl(NET_RT_IFLIST)/estimate");
return;
}
buf = malloc(needed);
if (buf == NULL) {
warn("malloc for sysctl(NET_RT_IFLIST) failed");
return;
}
if ((error = sysctl(mib, 6, buf, &needed, NULL, 0)) < 0) {
if (errno != ENOMEM || ++ntry >= MAX_SYSCTL_TRY) {
warn("sysctl(NET_RT_IFLIST)/get");
free(buf);
return;
}
free(buf);
buf = NULL;
}
} while (buf == NULL);
isinet6 = 0;
for (next = buf; next < buf + needed; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)next;
if (rtm->rtm_version != RTM_VERSION)
continue;
if (rtm->rtm_type == RTM_NEWADDR) {
isinet6 = 1;
break;
}
}
free(buf);
if (!isinet6)
return;
int isdefif;
memset(&nd, 0, sizeof(nd));
strncpy(nd.ifname, ifr.ifr_name, sizeof(nd.ifname));
if ((s6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
warn("socket(AF_INET6, SOCK_DGRAM)");
if (errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
warn("socket(AF_INET6, SOCK_DGRAM)");
return;
}
error = ioctl(s6, SIOCGIFINFO_IN6, &nd);
if (error) {
warn("ioctl(SIOCGIFINFO_IN6)");
if (errno != EPFNOSUPPORT)
warn("ioctl(SIOCGIFINFO_IN6)");
close(s6);
return;
}
@@ -217,19 +169,3 @@ nd6_status(int s)
(unsigned int)(nd.ndi.flags | (isdefif << 15)), ND6BITS);
putchar('\n');
}
static struct afswtch af_nd6 = {
.af_name = "nd6",
.af_af = AF_LOCAL,
.af_other_status= nd6_status,
};
#ifndef __rtems__
static __constructor void
#else /* __rtems__ */
void
#endif /* __rtems__ */
nd6_ctor(void)
{
af_register(&af_nd6);
}

View File

@@ -175,7 +175,6 @@ int rtems_bsd_command_ifconfig(int argc, char *argv[])
lagg_ctor();
link_ctor();
mac_ctor();
nd6_ctor();
pfsync_ctor();
vlan_ctor();
@@ -198,7 +197,7 @@ main(int argc, char *argv[])
struct ifaddrs *ifap, *ifa;
struct ifreq paifr;
const struct sockaddr_dl *sdl;
char options[1024], *cp;
char options[1024], *cp, *namecp = NULL;
const char *ifname;
struct option *p;
size_t iflen;
@@ -279,8 +278,10 @@ main(int argc, char *argv[])
ifindex = 0;
if (argc == 1) {
afp = af_getbyname(*argv);
if (afp == NULL)
if (afp == NULL) {
warnx("Address family '%s' unknown.", *argv);
usage();
}
if (afp->af_name != NULL)
argc--, argv++;
/* leave with afp non-zero */
@@ -354,7 +355,7 @@ main(int argc, char *argv[])
sdl = (const struct sockaddr_dl *) ifa->ifa_addr;
else
sdl = NULL;
if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0)
if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0 && !namesonly)
continue;
iflen = strlcpy(name, ifa->ifa_name, sizeof(name));
if (iflen >= sizeof(name)) {
@@ -370,16 +371,34 @@ main(int argc, char *argv[])
continue;
if (uponly && (ifa->ifa_flags & IFF_UP) == 0)
continue;
ifindex++;
/*
* Are we just listing the interfaces?
*/
if (namesonly) {
if (namecp == cp)
continue;
if (afp != NULL) {
/* special case for "ether" address family */
if (!strcmp(afp->af_name, "ether")) {
if (sdl == NULL ||
(sdl->sdl_type != IFT_ETHER &&
sdl->sdl_type != IFT_L2VLAN &&
sdl->sdl_type != IFT_BRIDGE) ||
sdl->sdl_alen != ETHER_ADDR_LEN)
continue;
} else {
if (ifa->ifa_addr->sa_family != afp->af_af)
continue;
}
}
namecp = cp;
ifindex++;
if (ifindex > 1)
printf(" ");
fputs(name, stdout);
continue;
}
ifindex++;
if (argc > 0)
ifconfig(argc, argv, 0, afp);
@@ -525,7 +544,30 @@ ifconfig(int argc, char *const *argv, int iscreate, const struct afswtch *uafp)
int s;
strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
afp = uafp != NULL ? uafp : af_getbyname("inet");
afp = NULL;
if (uafp != NULL)
afp = uafp;
/*
* This is the historical "accident" allowing users to configure IPv4
* addresses without the "inet" keyword which while a nice feature has
* proven to complicate other things. We cannot remove this but only
* make sure we will never have a similar implicit default for IPv6 or
* any other address familiy. We need a fallback though for
* ifconfig IF up/down etc. to work without INET support as people
* never used ifconfig IF link up/down, etc. either.
*/
#ifndef RESCUE
#ifdef INET
if (afp == NULL && feature_present("inet"))
afp = af_getbyname("inet");
#endif
#endif
if (afp == NULL)
afp = af_getbyname("link");
if (afp == NULL) {
warnx("Please specify an address_family.");
usage();
}
top:
ifr.ifr_addr.sa_family =
afp->af_af == AF_LINK || afp->af_af == AF_UNSPEC ?
@@ -928,7 +970,8 @@ unsetifdescr(const char *val, int value, int s, const struct afswtch *afp)
#define IFCAPBITS \
"\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \
"\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" \
"\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP"
"\17TOE4\20TOE6\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" \
"\26RXCSUM_IPV6\27TXCSUM_IPV6"
/*
* Print the status of the interface. If an address family was
@@ -1192,6 +1235,10 @@ static struct cmd basic_cmds[] = {
DEF_CMD("-monitor", -IFF_MONITOR, setifflags),
DEF_CMD("staticarp", IFF_STATICARP, setifflags),
DEF_CMD("-staticarp", -IFF_STATICARP, setifflags),
DEF_CMD("rxcsum6", IFCAP_RXCSUM_IPV6, setifcap),
DEF_CMD("-rxcsum6", -IFCAP_RXCSUM_IPV6, setifcap),
DEF_CMD("txcsum6", IFCAP_TXCSUM_IPV6, setifcap),
DEF_CMD("-txcsum6", -IFCAP_TXCSUM_IPV6, setifcap),
DEF_CMD("rxcsum", IFCAP_RXCSUM, setifcap),
DEF_CMD("-rxcsum", -IFCAP_RXCSUM, setifcap),
DEF_CMD("txcsum", IFCAP_TXCSUM, setifcap),
@@ -1200,8 +1247,14 @@ static struct cmd basic_cmds[] = {
DEF_CMD("-netcons", -IFCAP_NETCONS, setifcap),
DEF_CMD("polling", IFCAP_POLLING, setifcap),
DEF_CMD("-polling", -IFCAP_POLLING, setifcap),
DEF_CMD("tso6", IFCAP_TSO6, setifcap),
DEF_CMD("-tso6", -IFCAP_TSO6, setifcap),
DEF_CMD("tso4", IFCAP_TSO4, setifcap),
DEF_CMD("-tso4", -IFCAP_TSO4, setifcap),
DEF_CMD("tso", IFCAP_TSO, setifcap),
DEF_CMD("-tso", -IFCAP_TSO, setifcap),
DEF_CMD("toe", IFCAP_TOE, setifcap),
DEF_CMD("-toe", -IFCAP_TOE, setifcap),
DEF_CMD("lro", IFCAP_LRO, setifcap),
DEF_CMD("-lro", -IFCAP_LRO, setifcap),
DEF_CMD("wol", IFCAP_WOL, setifcap),

View File

@@ -166,7 +166,6 @@ void inet_ctor(void);
void lagg_ctor(void);
void link_ctor(void);
void mac_ctor(void);
void nd6_ctor(void);
void pfsync_ctor(void);
void vlan_ctor(void);

View File

@@ -53,38 +53,22 @@ static const char rcsid[] =
#include "ifconfig.h"
static void gif_status(int);
#define GIFBITS "\020\1ACCEPT_REV_ETHIP_VER\5SEND_REV_ETHIP_VER"
static const struct {
const char *label;
u_int mask;
} gif_opts[] = {
{ "ACCEPT_REV_ETHIP_VER", GIF_ACCEPT_REVETHIP },
{ "SEND_REV_ETHIP_VER", GIF_SEND_REVETHIP },
};
static void gif_status(int);
static void
gif_status(int s)
{
int opts;
int nopts = 0;
size_t i;
ifr.ifr_data = (caddr_t)&opts;
if (ioctl(s, GIFGOPTS, &ifr) == -1)
return;
if (opts == 0)
return;
printf("\toptions=%d<", opts);
for (i=0; i < sizeof(gif_opts)/sizeof(gif_opts[0]); i++) {
if (opts & gif_opts[i].mask) {
if (nopts++)
printf(",");
printf("%s", gif_opts[i].label);
}
}
printf(">\n");
printb("\toptions", opts, GIFBITS);
putchar('\n');
}
static void

View File

@@ -42,7 +42,8 @@ setlaggport(const char *val, int d, int s, const struct afswtch *afp)
strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
strlcpy(rp.rp_portname, val, sizeof(rp.rp_portname));
if (ioctl(s, SIOCSLAGGPORT, &rp))
/* Don't choke if the port is already in this lagg. */
if (ioctl(s, SIOCSLAGGPORT, &rp) && errno != EEXIST)
err(1, "SIOCSLAGGPORT");
}
@@ -99,10 +100,8 @@ setlagghash(const char *val, int d, int s, const struct afswtch *afp)
rf.rf_flags |= LAGG_F_HASHL3;
else if (strcmp(tok, "l4") == 0)
rf.rf_flags |= LAGG_F_HASHL4;
else {
free(str);
else
errx(1, "Invalid lagghash option: %s", tok);
}
}
free(str);
if (rf.rf_flags == 0)

View File

@@ -47,10 +47,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.