diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-08-21 13:47:02 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-09-21 10:29:41 +0200 |
commit | bcdce02d9bc8150e1d191ed5ca9da45b7604964a (patch) | |
tree | 3b2faf509db7672ee1fc98857736470be97e7ed8 /freebsd/sbin | |
parent | Update to FreeBSD head 2018-04-01 (diff) | |
download | rtems-libbsd-bcdce02d9bc8150e1d191ed5ca9da45b7604964a.tar.bz2 |
Update to FreeBSD head 2018-06-01
Git mirror commit fb63610a69b0eb7f69a201ba05c4c1a7a2739cf9.
Update #3472.
Diffstat (limited to 'freebsd/sbin')
-rw-r--r-- | freebsd/sbin/dhclient/dhclient.c | 18 | ||||
-rw-r--r-- | freebsd/sbin/ifconfig/ifclone.c | 2 | ||||
-rw-r--r-- | freebsd/sbin/ifconfig/ifconfig.c | 11 | ||||
-rw-r--r-- | freebsd/sbin/ifconfig/ifconfig.h | 1 | ||||
-rw-r--r-- | freebsd/sbin/ifconfig/ifgroup.c | 4 | ||||
-rw-r--r-- | freebsd/sbin/ifconfig/iflagg.c | 14 | ||||
-rw-r--r-- | freebsd/sbin/ifconfig/ifmedia.c | 62 | ||||
-rw-r--r-- | freebsd/sbin/ifconfig/rtems-bsd-ifconfig-data.h | 1 | ||||
-rw-r--r-- | freebsd/sbin/ifconfig/rtems-bsd-ifconfig-ifmedia-data.h | 6 | ||||
-rw-r--r-- | freebsd/sbin/ifconfig/rtems-bsd-ifconfig-namespace.h | 1 | ||||
-rw-r--r-- | freebsd/sbin/pfctl/pfctl.c | 47 | ||||
-rw-r--r-- | freebsd/sbin/pfctl/rtems-bsd-pfctl-namespace.h | 3 | ||||
-rw-r--r-- | freebsd/sbin/pfctl/rtems-bsd-pfctl-pfctl-data.h | 1 |
13 files changed, 88 insertions, 83 deletions
diff --git a/freebsd/sbin/dhclient/dhclient.c b/freebsd/sbin/dhclient/dhclient.c index d9bae19c..e0af9431 100644 --- a/freebsd/sbin/dhclient/dhclient.c +++ b/freebsd/sbin/dhclient/dhclient.c @@ -851,11 +851,23 @@ bind_lease(struct interface_info *ip) opt = &ip->client->new->options[DHO_INTERFACE_MTU]; if (opt->len == sizeof(u_int16_t)) { - u_int16_t mtu = be16dec(opt->data); - if (mtu < MIN_MTU) - warning("mtu size %u < %d: ignored", (unsigned)mtu, MIN_MTU); + u_int16_t mtu = 0; + bool supersede = (ip->client->config->default_actions[DHO_INTERFACE_MTU] == + ACTION_SUPERSEDE); + + if (supersede) + mtu = getUShort(ip->client->config->defaults[DHO_INTERFACE_MTU].data); else + mtu = be16dec(opt->data); + + if (mtu < MIN_MTU) { + /* Treat 0 like a user intentionally doesn't want to change MTU and, + * therefore, warning is not needed */ + if (!supersede || mtu != 0) + warning("mtu size %u < %d: ignored", (unsigned)mtu, MIN_MTU); + } else { interface_set_mtu_unpriv(privfd, mtu); + } } /* Write out the new lease. */ diff --git a/freebsd/sbin/ifconfig/ifclone.c b/freebsd/sbin/ifconfig/ifclone.c index 749e12c0..ee1f7b22 100644 --- a/freebsd/sbin/ifconfig/ifclone.c +++ b/freebsd/sbin/ifconfig/ifclone.c @@ -202,7 +202,7 @@ static void clone_Copt_cb(const char *optarg __unused) { list_cloners(); - exit(0); + exit(exit_code); } static struct option clone_Copt = { .opt = "C", .opt_usage = "[-C]", .cb = clone_Copt_cb }; diff --git a/freebsd/sbin/ifconfig/ifconfig.c b/freebsd/sbin/ifconfig/ifconfig.c index e625e42b..56b4f6d7 100644 --- a/freebsd/sbin/ifconfig/ifconfig.c +++ b/freebsd/sbin/ifconfig/ifconfig.c @@ -117,6 +117,7 @@ int printifname = 0; int supmedia = 0; int printkeys = 0; /* Print keying material for interfaces. */ +int exit_code = 0; /* Formatter Strings */ char *f_inet, *f_inet6, *f_ether, *f_addr; @@ -566,7 +567,7 @@ main(int argc, char *argv[]) errx(1, "%s: cloning name too long", ifname); ifconfig(argc, argv, 1, NULL); - exit(0); + exit(exit_code); } #ifdef JAIL /* @@ -580,7 +581,7 @@ main(int argc, char *argv[]) errx(1, "%s: interface name too long", ifname); ifconfig(argc, argv, 0, NULL); - exit(0); + exit(exit_code); } #endif errx(1, "interface %s does not exist", ifname); @@ -678,7 +679,7 @@ main(int argc, char *argv[]) freeifaddrs(ifap); freeformat(); - exit(0); + exit(exit_code); } static struct afswtch *afs = NULL; @@ -1573,8 +1574,8 @@ static struct cmd basic_cmds[] = { DEF_CMD("-wol_magic", -IFCAP_WOL_MAGIC, setifcap), DEF_CMD("txrtlmt", IFCAP_TXRTLMT, setifcap), DEF_CMD("-txrtlmt", -IFCAP_TXRTLMT, setifcap), - DEF_CMD("hwrxtsmp", IFCAP_HWRXTSTMP, setifcap), - DEF_CMD("-hwrxtsmp", -IFCAP_HWRXTSTMP, setifcap), + DEF_CMD("hwrxtstmp", IFCAP_HWRXTSTMP, setifcap), + DEF_CMD("-hwrxtstmp", -IFCAP_HWRXTSTMP, setifcap), DEF_CMD("normal", -IFF_LINK0, setifflags), DEF_CMD("compress", IFF_LINK0, setifflags), DEF_CMD("noicmp", IFF_LINK1, setifflags), diff --git a/freebsd/sbin/ifconfig/ifconfig.h b/freebsd/sbin/ifconfig/ifconfig.h index 97fe20e1..0e2fcba2 100644 --- a/freebsd/sbin/ifconfig/ifconfig.h +++ b/freebsd/sbin/ifconfig/ifconfig.h @@ -136,6 +136,7 @@ extern int printkeys; extern int newaddr; extern int verbose; extern int printifname; +extern int exit_code; void setifcap(const char *, int value, int s, const struct afswtch *); diff --git a/freebsd/sbin/ifconfig/ifgroup.c b/freebsd/sbin/ifconfig/ifgroup.c index ae8e2b8d..a487f060 100644 --- a/freebsd/sbin/ifconfig/ifgroup.c +++ b/freebsd/sbin/ifconfig/ifgroup.c @@ -162,7 +162,7 @@ printgroup(const char *groupname) if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) { if (errno == EINVAL || errno == ENOTTY || errno == ENOENT) - exit(0); + exit(exit_code); else err(1, "SIOCGIFGMEMB"); } @@ -181,7 +181,7 @@ printgroup(const char *groupname) } free(ifgr.ifgr_groups); - exit(0); + exit(exit_code); } static struct cmd group_cmds[] = { diff --git a/freebsd/sbin/ifconfig/iflagg.c b/freebsd/sbin/ifconfig/iflagg.c index d659ed57..4952196a 100644 --- a/freebsd/sbin/ifconfig/iflagg.c +++ b/freebsd/sbin/ifconfig/iflagg.c @@ -53,9 +53,17 @@ 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)); - /* Don't choke if the port is already in this lagg. */ - if (ioctl(s, SIOCSLAGGPORT, &rp) && errno != EEXIST) - err(1, "SIOCSLAGGPORT"); + /* + * Do not exit with an error here. Doing so permits a + * failed NIC to take down an entire lagg. + * + * Don't error at all if the port is already in the lagg. + */ + if (ioctl(s, SIOCSLAGGPORT, &rp) && errno != EEXIST) { + warnx("%s %s: SIOCSLAGGPORT: %s", + name, val, strerror(errno)); + exit_code = 1; + } } static void diff --git a/freebsd/sbin/ifconfig/ifmedia.c b/freebsd/sbin/ifconfig/ifmedia.c index b986d548..ac2af8b6 100644 --- a/freebsd/sbin/ifconfig/ifmedia.c +++ b/freebsd/sbin/ifconfig/ifmedia.c @@ -195,14 +195,6 @@ media_status(int s) printf("no carrier"); break; - case IFM_FDDI: - case IFM_TOKEN: - if (ifmr.ifm_status & IFM_ACTIVE) - printf("inserted"); - else - printf("no ring"); - break; - case IFM_IEEE80211: if (ifmr.ifm_status & IFM_ACTIVE) { /* NB: only sta mode associates */ @@ -430,24 +422,6 @@ static struct ifmedia_description ifm_subtype_ethernet_aliases[] = static struct ifmedia_description ifm_subtype_ethernet_option_descriptions[] = IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS; -static struct ifmedia_description ifm_subtype_tokenring_descriptions[] = - IFM_SUBTYPE_TOKENRING_DESCRIPTIONS; - -static struct ifmedia_description ifm_subtype_tokenring_aliases[] = - IFM_SUBTYPE_TOKENRING_ALIASES; - -static struct ifmedia_description ifm_subtype_tokenring_option_descriptions[] = - IFM_SUBTYPE_TOKENRING_OPTION_DESCRIPTIONS; - -static struct ifmedia_description ifm_subtype_fddi_descriptions[] = - IFM_SUBTYPE_FDDI_DESCRIPTIONS; - -static struct ifmedia_description ifm_subtype_fddi_aliases[] = - IFM_SUBTYPE_FDDI_ALIASES; - -static struct ifmedia_description ifm_subtype_fddi_option_descriptions[] = - IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS; - static struct ifmedia_description ifm_subtype_ieee80211_descriptions[] = IFM_SUBTYPE_IEEE80211_DESCRIPTIONS; @@ -525,42 +499,6 @@ static struct ifmedia_type_to_subtype ifmedia_types_to_subtypes[] = { { { &ifm_subtype_shared_descriptions[0], 0 }, { &ifm_subtype_shared_aliases[0], 1 }, - { &ifm_subtype_tokenring_descriptions[0], 0 }, - { &ifm_subtype_tokenring_aliases[0], 1 }, - { NULL, 0 }, - }, - { - { &ifm_shared_option_descriptions[0], 0 }, - { &ifm_shared_option_aliases[0], 1 }, - { &ifm_subtype_tokenring_option_descriptions[0], 0 }, - { NULL, 0 }, - }, - { - { NULL, 0 }, - }, - }, - { - { - { &ifm_subtype_shared_descriptions[0], 0 }, - { &ifm_subtype_shared_aliases[0], 1 }, - { &ifm_subtype_fddi_descriptions[0], 0 }, - { &ifm_subtype_fddi_aliases[0], 1 }, - { NULL, 0 }, - }, - { - { &ifm_shared_option_descriptions[0], 0 }, - { &ifm_shared_option_aliases[0], 1 }, - { &ifm_subtype_fddi_option_descriptions[0], 0 }, - { NULL, 0 }, - }, - { - { NULL, 0 }, - }, - }, - { - { - { &ifm_subtype_shared_descriptions[0], 0 }, - { &ifm_subtype_shared_aliases[0], 1 }, { &ifm_subtype_ieee80211_descriptions[0], 0 }, { &ifm_subtype_ieee80211_aliases[0], 1 }, { NULL, 0 }, diff --git a/freebsd/sbin/ifconfig/rtems-bsd-ifconfig-data.h b/freebsd/sbin/ifconfig/rtems-bsd-ifconfig-data.h index 3b1956ea..a605646d 100644 --- a/freebsd/sbin/ifconfig/rtems-bsd-ifconfig-data.h +++ b/freebsd/sbin/ifconfig/rtems-bsd-ifconfig-data.h @@ -15,6 +15,7 @@ RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern char *f_inet6); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern char name[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int clearaddr); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int doalias); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int exit_code); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int newaddr); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int noload); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, extern int printifname); diff --git a/freebsd/sbin/ifconfig/rtems-bsd-ifconfig-ifmedia-data.h b/freebsd/sbin/ifconfig/rtems-bsd-ifconfig-ifmedia-data.h index 84d16c92..911589ac 100644 --- a/freebsd/sbin/ifconfig/rtems-bsd-ifconfig-ifmedia-data.h +++ b/freebsd/sbin/ifconfig/rtems-bsd-ifconfig-ifmedia-data.h @@ -13,17 +13,11 @@ RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_ethernet_aliases[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_ethernet_descriptions[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_ethernet_option_descriptions[]); -RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_fddi_aliases[]); -RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_fddi_descriptions[]); -RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_fddi_option_descriptions[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_ieee80211_aliases[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_ieee80211_descriptions[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_ieee80211_option_descriptions[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_shared_aliases[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_shared_descriptions[]); -RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_tokenring_aliases[]); -RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_tokenring_descriptions[]); -RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_subtype_tokenring_option_descriptions[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_description ifm_type_descriptions[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmedia_type_to_subtype ifmedia_types_to_subtypes[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_ifconfig, static struct ifmediareq *ifmedia_getstate_ifmr); diff --git a/freebsd/sbin/ifconfig/rtems-bsd-ifconfig-namespace.h b/freebsd/sbin/ifconfig/rtems-bsd-ifconfig-namespace.h index 03cd73d6..e7488dfe 100644 --- a/freebsd/sbin/ifconfig/rtems-bsd-ifconfig-namespace.h +++ b/freebsd/sbin/ifconfig/rtems-bsd-ifconfig-namespace.h @@ -23,6 +23,7 @@ #define descr _bsd_ifconfig_descr #define descrlen _bsd_ifconfig_descrlen #define doalias _bsd_ifconfig_doalias +#define exit_code _bsd_ifconfig_exit_code #define f_addr _bsd_ifconfig_f_addr #define f_ether _bsd_ifconfig_f_ether #define f_inet _bsd_ifconfig_f_inet diff --git a/freebsd/sbin/pfctl/pfctl.c b/freebsd/sbin/pfctl/pfctl.c index c814a816..ca7d6f38 100644 --- a/freebsd/sbin/pfctl/pfctl.c +++ b/freebsd/sbin/pfctl/pfctl.c @@ -85,6 +85,9 @@ void usage(void); int pfctl_enable(int, int); int pfctl_disable(int, int); int pfctl_clear_stats(int, int); +int pfctl_get_skip_ifaces(void); +int pfctl_check_skip_ifaces(char *); +int pfctl_clear_skip_ifaces(struct pfctl *); int pfctl_clear_interface_flags(int, int); int pfctl_clear_rules(int, int, char *); int pfctl_clear_nat(int, int, char *); @@ -124,6 +127,7 @@ const char *pfctl_lookup_option(char *, const char * const *); static struct pf_anchor_global pf_anchors; static struct pf_anchor pf_main_anchor; +static struct pfr_buffer skip_b; static const char *clearopt; static char *rulesopt; @@ -317,6 +321,44 @@ pfctl_clear_stats(int dev, int opts) } int +pfctl_get_skip_ifaces(void) +{ + bzero(&skip_b, sizeof(skip_b)); + skip_b.pfrb_type = PFRB_IFACES; + for (;;) { + pfr_buf_grow(&skip_b, skip_b.pfrb_size); + skip_b.pfrb_size = skip_b.pfrb_msize; + if (pfi_get_ifaces(NULL, skip_b.pfrb_caddr, &skip_b.pfrb_size)) + err(1, "pfi_get_ifaces"); + if (skip_b.pfrb_size <= skip_b.pfrb_msize) + break; + } + return (0); +} + +int +pfctl_check_skip_ifaces(char *ifname) +{ + struct pfi_kif *p; + + PFRB_FOREACH(p, &skip_b) + if ((p->pfik_flags & PFI_IFLAG_SKIP) && !strcmp(ifname, p->pfik_name)) + p->pfik_flags &= ~PFI_IFLAG_SKIP; + return (0); +} + +int +pfctl_clear_skip_ifaces(struct pfctl *pf) +{ + struct pfi_kif *p; + + PFRB_FOREACH(p, &skip_b) + if (p->pfik_flags & PFI_IFLAG_SKIP) + pfctl_set_interface_flags(pf, p->pfik_name, PFI_IFLAG_SKIP, 0); + return (0); +} + +int pfctl_clear_interface_flags(int dev, int opts) { struct pfioc_iface pi; @@ -1505,6 +1547,8 @@ pfctl_rules(int dev, char *filename, int opts, int optimize, else goto _error; } + if (loadopt & PFCTL_FLAG_OPTION) + pfctl_clear_skip_ifaces(&pf); if ((pf.loadopt & PFCTL_FLAG_FILTER && (pfctl_load_ruleset(&pf, path, rs, PF_RULESET_SCRUB, 0))) || @@ -1915,6 +1959,7 @@ pfctl_set_interface_flags(struct pfctl *pf, char *ifname, int flags, int how) } else { if (ioctl(pf->dev, DIOCSETIFFLAG, &pi)) err(1, "DIOCSETIFFLAG"); + pfctl_check_skip_ifaces(ifname); } } return (0); @@ -2405,7 +2450,7 @@ main(int argc, char *argv[]) if ((rulesopt != NULL) && (loadopt & PFCTL_FLAG_OPTION) && !anchorname[0]) - if (pfctl_clear_interface_flags(dev, opts | PF_OPT_QUIET)) + if (pfctl_get_skip_ifaces()) error = 1; if (rulesopt != NULL && !(opts & (PF_OPT_MERGE|PF_OPT_NOACTION)) && diff --git a/freebsd/sbin/pfctl/rtems-bsd-pfctl-namespace.h b/freebsd/sbin/pfctl/rtems-bsd-pfctl-namespace.h index 8aba20df..46053fd9 100644 --- a/freebsd/sbin/pfctl/rtems-bsd-pfctl-namespace.h +++ b/freebsd/sbin/pfctl/rtems-bsd-pfctl-namespace.h @@ -79,11 +79,13 @@ #define pfctl_add_pool _bsd_pfctl_pfctl_add_pool #define pfctl_add_rule _bsd_pfctl_pfctl_add_rule #define pfctl_addrprefix _bsd_pfctl_pfctl_addrprefix +#define pfctl_check_skip_ifaces _bsd_pfctl_pfctl_check_skip_ifaces #define pfctl_clear_altq _bsd_pfctl_pfctl_clear_altq #define pfctl_clear_interface_flags _bsd_pfctl_pfctl_clear_interface_flags #define pfctl_clear_nat _bsd_pfctl_pfctl_clear_nat #define pfctl_clear_pool _bsd_pfctl_pfctl_clear_pool #define pfctl_clear_rules _bsd_pfctl_pfctl_clear_rules +#define pfctl_clear_skip_ifaces _bsd_pfctl_pfctl_clear_skip_ifaces #define pfctl_clear_src_nodes _bsd_pfctl_pfctl_clear_src_nodes #define pfctl_clear_states _bsd_pfctl_pfctl_clear_states #define pfctl_clear_stats _bsd_pfctl_pfctl_clear_stats @@ -92,6 +94,7 @@ #define pfctl_enable _bsd_pfctl_pfctl_enable #define pfctl_fopen _bsd_pfctl_pfctl_fopen #define pfctl_get_pool _bsd_pfctl_pfctl_get_pool +#define pfctl_get_skip_ifaces _bsd_pfctl_pfctl_get_skip_ifaces #define pfctl_id_kill_states _bsd_pfctl_pfctl_id_kill_states #define pfctl_init_options _bsd_pfctl_pfctl_init_options #define pfctl_kill_src_nodes _bsd_pfctl_pfctl_kill_src_nodes diff --git a/freebsd/sbin/pfctl/rtems-bsd-pfctl-pfctl-data.h b/freebsd/sbin/pfctl/rtems-bsd-pfctl-pfctl-data.h index 614cb6b2..3fba09b1 100644 --- a/freebsd/sbin/pfctl/rtems-bsd-pfctl-pfctl-data.h +++ b/freebsd/sbin/pfctl/rtems-bsd-pfctl-pfctl-data.h @@ -20,3 +20,4 @@ RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int src_node_killers); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int state_killers); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct pf_anchor pf_main_anchor); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct pf_anchor_global pf_anchors); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static struct pfr_buffer skip_b); |