mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 18:25:52 +08:00
Update to FreeBSD head 2016-12-10
Git mirror commit 80c55f08a05ab3b26a73b226ccb56adc3122a55c.
This commit is contained in:
@@ -104,6 +104,8 @@ read_client_conf(void)
|
||||
[top_level_config.requested_option_count++] = DHO_HOST_NAME;
|
||||
top_level_config.requested_options
|
||||
[top_level_config.requested_option_count++] = DHO_DOMAIN_SEARCH;
|
||||
top_level_config.requested_options
|
||||
[top_level_config.requested_option_count++] = DHO_INTERFACE_MTU;
|
||||
|
||||
if ((cfile = fopen(path_dhclient_conf, "r")) != NULL) {
|
||||
do {
|
||||
|
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "privsep.h"
|
||||
|
||||
#include <sys/capsicum.h>
|
||||
#include <sys/endian.h>
|
||||
|
||||
#include <net80211/ieee80211_freebsd.h>
|
||||
|
||||
@@ -134,6 +135,9 @@ int fork_privchld(int, int);
|
||||
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
|
||||
#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
|
||||
|
||||
/* Minimum MTU is 68 as per RFC791, p. 24 */
|
||||
#define MIN_MTU 68
|
||||
|
||||
static time_t scripttime;
|
||||
|
||||
int
|
||||
@@ -800,9 +804,20 @@ dhcpack(struct packet *packet)
|
||||
void
|
||||
bind_lease(struct interface_info *ip)
|
||||
{
|
||||
struct option_data *opt;
|
||||
|
||||
/* Remember the medium. */
|
||||
ip->client->new->medium = ip->client->medium;
|
||||
|
||||
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);
|
||||
else
|
||||
interface_set_mtu_unpriv(privfd, mtu);
|
||||
}
|
||||
|
||||
/* Write out the new lease. */
|
||||
write_client_lease(ip, ip->client->new, 0);
|
||||
|
||||
|
@@ -319,6 +319,8 @@ void cancel_timeout(void (*)(void *), void *);
|
||||
void add_protocol(char *, int, void (*)(struct protocol *), void *);
|
||||
void remove_protocol(struct protocol *);
|
||||
int interface_link_status(char *);
|
||||
void interface_set_mtu_unpriv(int, u_int16_t);
|
||||
void interface_set_mtu_priv(char *, u_int16_t);
|
||||
|
||||
/* hash.c */
|
||||
struct hash_table *new_hash(void);
|
||||
|
@@ -45,6 +45,7 @@
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "dhcpd.h"
|
||||
#include "privsep.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@@ -107,8 +108,8 @@ discover_interfaces(struct interface_info *iface)
|
||||
if (foo.sin_addr.s_addr == htonl(INADDR_LOOPBACK))
|
||||
continue;
|
||||
if (!iface->ifp) {
|
||||
int len = IFNAMSIZ + ifa->ifa_addr->sa_len;
|
||||
if ((tif = malloc(len)) == NULL)
|
||||
if ((tif = calloc(1, sizeof(struct ifreq)))
|
||||
== NULL)
|
||||
error("no space to remember ifp");
|
||||
strlcpy(tif->ifr_name, ifa->ifa_name, IFNAMSIZ);
|
||||
memcpy(&tif->ifr_addr, ifa->ifa_addr,
|
||||
@@ -503,3 +504,46 @@ interface_link_status(char *ifname)
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
interface_set_mtu_unpriv(int privfd, u_int16_t mtu)
|
||||
{
|
||||
struct imsg_hdr hdr;
|
||||
struct buf *buf;
|
||||
int errs = 0;
|
||||
|
||||
hdr.code = IMSG_SET_INTERFACE_MTU;
|
||||
hdr.len = sizeof(hdr) +
|
||||
sizeof(u_int16_t);
|
||||
|
||||
if ((buf = buf_open(hdr.len)) == NULL)
|
||||
error("buf_open: %m");
|
||||
|
||||
errs += buf_add(buf, &hdr, sizeof(hdr));
|
||||
errs += buf_add(buf, &mtu, sizeof(mtu));
|
||||
if (errs)
|
||||
error("buf_add: %m");
|
||||
|
||||
if (buf_close(privfd, buf) == -1)
|
||||
error("buf_close: %m");
|
||||
}
|
||||
|
||||
void
|
||||
interface_set_mtu_priv(char *ifname, u_int16_t mtu)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
int sock;
|
||||
|
||||
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
|
||||
error("Can't create socket");
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
|
||||
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_mtu = mtu;
|
||||
|
||||
if (ioctl(sock, SIOCSIFMTU, &ifr) == -1)
|
||||
warning("SIOCSIFMTU failed (%d): %s", mtu,
|
||||
strerror(errno));
|
||||
close(sock);
|
||||
}
|
||||
|
@@ -113,6 +113,7 @@ dispatch_imsg(struct interface_info *ifi, int fd)
|
||||
struct client_lease lease;
|
||||
int ret, i, optlen;
|
||||
struct buf *buf;
|
||||
u_int16_t mtu;
|
||||
|
||||
buf_read(fd, &hdr, sizeof(hdr));
|
||||
|
||||
@@ -237,6 +238,13 @@ dispatch_imsg(struct interface_info *ifi, int fd)
|
||||
case IMSG_SEND_PACKET:
|
||||
send_packet_priv(ifi, &hdr, fd);
|
||||
break;
|
||||
case IMSG_SET_INTERFACE_MTU:
|
||||
if (hdr.len < sizeof(hdr) + sizeof(u_int16_t))
|
||||
error("corrupted message received");
|
||||
|
||||
buf_read(fd, &mtu, sizeof(u_int16_t));
|
||||
interface_set_mtu_priv(ifi->name, mtu);
|
||||
break;
|
||||
default:
|
||||
error("received unknown message, code %d", hdr.code);
|
||||
}
|
||||
|
@@ -36,7 +36,8 @@ enum imsg_code {
|
||||
IMSG_SCRIPT_WRITE_PARAMS,
|
||||
IMSG_SCRIPT_GO,
|
||||
IMSG_SCRIPT_GO_RET,
|
||||
IMSG_SEND_PACKET
|
||||
IMSG_SEND_PACKET,
|
||||
IMSG_SET_INTERFACE_MTU,
|
||||
};
|
||||
|
||||
struct imsg_hdr {
|
||||
|
@@ -402,6 +402,7 @@ unsigned char dhcp_option_default_priority_list[] = {
|
||||
DHO_IRC_SERVER,
|
||||
DHO_STREETTALK_SERVER,
|
||||
DHO_STREETTALK_DA_SERVER,
|
||||
DHO_DHCP_USER_CLASS_ID,
|
||||
DHO_DOMAIN_SEARCH,
|
||||
|
||||
/* Presently-undefined options... */
|
||||
|
@@ -100,7 +100,7 @@ in_status(int s __unused, const struct ifaddrs *ifa)
|
||||
sin = (struct sockaddr_in *)ifa->ifa_dstaddr;
|
||||
if (sin == NULL)
|
||||
sin = &null_sin;
|
||||
printf(" --> %s ", inet_ntoa(sin->sin_addr));
|
||||
printf(" --> %s", inet_ntoa(sin->sin_addr));
|
||||
}
|
||||
|
||||
sin = (struct sockaddr_in *)ifa->ifa_netmask;
|
||||
|
@@ -250,7 +250,7 @@ in6_status(int s __unused, const struct ifaddrs *ifa)
|
||||
if (error != 0)
|
||||
inet_ntop(AF_INET6, &sin->sin6_addr, addr_buf,
|
||||
sizeof(addr_buf));
|
||||
printf(" --> %s ", addr_buf);
|
||||
printf(" --> %s", addr_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -102,13 +102,24 @@ link_getaddr(const char *addr, int which)
|
||||
|
||||
if (which != ADDR)
|
||||
errx(1, "can't set link-level netmask or broadcast");
|
||||
if ((temp = malloc(strlen(addr) + 2)) == NULL)
|
||||
errx(1, "malloc failed");
|
||||
temp[0] = ':';
|
||||
strcpy(temp + 1, addr);
|
||||
sdl.sdl_len = sizeof(sdl);
|
||||
link_addr(temp, &sdl);
|
||||
free(temp);
|
||||
if (!strcmp(addr, "random")) {
|
||||
sdl.sdl_len = sizeof(sdl);
|
||||
sdl.sdl_alen = ETHER_ADDR_LEN;
|
||||
sdl.sdl_nlen = 0;
|
||||
sdl.sdl_family = AF_LINK;
|
||||
arc4random_buf(&sdl.sdl_data, ETHER_ADDR_LEN);
|
||||
/* Non-multicast and claim it is locally administered. */
|
||||
sdl.sdl_data[0] &= 0xfc;
|
||||
sdl.sdl_data[0] |= 0x02;
|
||||
} else {
|
||||
if ((temp = malloc(strlen(addr) + 2)) == NULL)
|
||||
errx(1, "malloc failed");
|
||||
temp[0] = ':';
|
||||
strcpy(temp + 1, addr);
|
||||
sdl.sdl_len = sizeof(sdl);
|
||||
link_addr(temp, &sdl);
|
||||
free(temp);
|
||||
}
|
||||
if (sdl.sdl_alen > sizeof(sa->sa_data))
|
||||
errx(1, "malformed link-level address");
|
||||
sa->sa_family = AF_LINK;
|
||||
|
@@ -367,6 +367,8 @@ void decide_address_family(struct node_host *, sa_family_t *);
|
||||
void remove_invalid_hosts(struct node_host **, sa_family_t *);
|
||||
int invalid_redirect(struct node_host *, sa_family_t);
|
||||
u_int16_t parseicmpspec(char *, sa_family_t);
|
||||
int kw_casecmp(const void *, const void *);
|
||||
int map_tos(char *string, int *);
|
||||
|
||||
static TAILQ_HEAD(loadanchorshead, loadanchors)
|
||||
loadanchorshead = TAILQ_HEAD_INITIALIZER(loadanchorshead);
|
||||
@@ -2346,7 +2348,7 @@ pfrule : action dir logquick interface route af proto fromto
|
||||
memcpy(&r.rpool.key, $5.key,
|
||||
sizeof(struct pf_poolhashkey));
|
||||
}
|
||||
if (r.rt && r.rt != PF_FASTROUTE) {
|
||||
if (r.rt) {
|
||||
decide_address_family($5.host, &r.af);
|
||||
remove_invalid_hosts(&$5.host, &r.af);
|
||||
if ($5.host == NULL) {
|
||||
@@ -3600,15 +3602,17 @@ icmp6type : STRING {
|
||||
;
|
||||
|
||||
tos : STRING {
|
||||
if (!strcmp($1, "lowdelay"))
|
||||
$$ = IPTOS_LOWDELAY;
|
||||
else if (!strcmp($1, "throughput"))
|
||||
$$ = IPTOS_THROUGHPUT;
|
||||
else if (!strcmp($1, "reliability"))
|
||||
$$ = IPTOS_RELIABILITY;
|
||||
else if ($1[0] == '0' && $1[1] == 'x')
|
||||
$$ = strtoul($1, NULL, 16);
|
||||
else
|
||||
int val;
|
||||
char *end;
|
||||
|
||||
if (map_tos($1, &val))
|
||||
$$ = val;
|
||||
else if ($1[0] == '0' && $1[1] == 'x') {
|
||||
errno = 0;
|
||||
$$ = strtoul($1, &end, 16);
|
||||
if (errno || *end != '\0')
|
||||
$$ = 256;
|
||||
} else
|
||||
$$ = 256; /* flag bad argument */
|
||||
if ($$ < 0 || $$ > 255) {
|
||||
yyerror("illegal tos value %s", $1);
|
||||
@@ -4432,8 +4436,9 @@ route : /* empty */ {
|
||||
$$.pool_opts = 0;
|
||||
}
|
||||
| FASTROUTE {
|
||||
/* backwards-compat */
|
||||
$$.host = NULL;
|
||||
$$.rt = PF_FASTROUTE;
|
||||
$$.rt = 0;
|
||||
$$.pool_opts = 0;
|
||||
}
|
||||
| ROUTETO routespec pool_opts {
|
||||
@@ -6269,6 +6274,57 @@ pfctl_load_anchors(int dev, struct pfctl *pf, struct pfr_buffer *trans)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
kw_casecmp(const void *k, const void *e)
|
||||
{
|
||||
return (strcasecmp(k, ((const struct keywords *)e)->k_name));
|
||||
}
|
||||
|
||||
int
|
||||
map_tos(char *s, int *val)
|
||||
{
|
||||
/* DiffServ Codepoints and other TOS mappings */
|
||||
const struct keywords toswords[] = {
|
||||
{ "af11", IPTOS_DSCP_AF11 },
|
||||
{ "af12", IPTOS_DSCP_AF12 },
|
||||
{ "af13", IPTOS_DSCP_AF13 },
|
||||
{ "af21", IPTOS_DSCP_AF21 },
|
||||
{ "af22", IPTOS_DSCP_AF22 },
|
||||
{ "af23", IPTOS_DSCP_AF23 },
|
||||
{ "af31", IPTOS_DSCP_AF31 },
|
||||
{ "af32", IPTOS_DSCP_AF32 },
|
||||
{ "af33", IPTOS_DSCP_AF33 },
|
||||
{ "af41", IPTOS_DSCP_AF41 },
|
||||
{ "af42", IPTOS_DSCP_AF42 },
|
||||
{ "af43", IPTOS_DSCP_AF43 },
|
||||
{ "critical", IPTOS_PREC_CRITIC_ECP },
|
||||
{ "cs0", IPTOS_DSCP_CS0 },
|
||||
{ "cs1", IPTOS_DSCP_CS1 },
|
||||
{ "cs2", IPTOS_DSCP_CS2 },
|
||||
{ "cs3", IPTOS_DSCP_CS3 },
|
||||
{ "cs4", IPTOS_DSCP_CS4 },
|
||||
{ "cs5", IPTOS_DSCP_CS5 },
|
||||
{ "cs6", IPTOS_DSCP_CS6 },
|
||||
{ "cs7", IPTOS_DSCP_CS7 },
|
||||
{ "ef", IPTOS_DSCP_EF },
|
||||
{ "inetcontrol", IPTOS_PREC_INTERNETCONTROL },
|
||||
{ "lowdelay", IPTOS_LOWDELAY },
|
||||
{ "netcontrol", IPTOS_PREC_NETCONTROL },
|
||||
{ "reliability", IPTOS_RELIABILITY },
|
||||
{ "throughput", IPTOS_THROUGHPUT }
|
||||
};
|
||||
const struct keywords *p;
|
||||
|
||||
p = bsearch(s, toswords, sizeof(toswords)/sizeof(toswords[0]),
|
||||
sizeof(toswords[0]), kw_casecmp);
|
||||
|
||||
if (p) {
|
||||
*val = p->k_val;
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
rt_tableid_max(void)
|
||||
{
|
||||
|
@@ -1364,7 +1364,7 @@ pfctl_load_rule(struct pfctl *pf, char *path, struct pf_rule *r, int depth)
|
||||
else
|
||||
snprintf(&path[len], MAXPATHLEN - len,
|
||||
"%s", r->anchor->name);
|
||||
name = path;
|
||||
name = r->anchor->name;
|
||||
} else
|
||||
name = r->anchor->path;
|
||||
} else
|
||||
|
@@ -103,7 +103,7 @@ TAILQ_HEAD(superblocks, superblock);
|
||||
* Description of the PF rule structure.
|
||||
*/
|
||||
enum {
|
||||
BARRIER, /* the presence of the field puts the rule in it's own block */
|
||||
BARRIER, /* the presence of the field puts the rule in its own block */
|
||||
BREAK, /* the field may not differ between rules in a superblock */
|
||||
NOMERGE, /* the field may not differ between rules when combined */
|
||||
COMBINED, /* the field may itself be combined with other rules */
|
||||
@@ -127,7 +127,7 @@ static struct pf_rule_field pf_rule_desc[] = {
|
||||
|
||||
|
||||
/*
|
||||
* The presence of these fields in a rule put the rule in it's own
|
||||
* The presence of these fields in a rule put the rule in its own
|
||||
* superblock. Thus it will not be optimized. It also prevents the
|
||||
* rule from being re-ordered at all.
|
||||
*/
|
||||
|
@@ -790,12 +790,8 @@ print_rule(struct pf_rule *r, const char *anchor_call, int verbose, int numeric)
|
||||
printf(" reply-to");
|
||||
else if (r->rt == PF_DUPTO)
|
||||
printf(" dup-to");
|
||||
else if (r->rt == PF_FASTROUTE)
|
||||
printf(" fastroute");
|
||||
if (r->rt != PF_FASTROUTE) {
|
||||
printf(" ");
|
||||
print_pool(&r->rpool, 0, 0, r->af, PF_PASS);
|
||||
}
|
||||
printf(" ");
|
||||
print_pool(&r->rpool, 0, 0, r->af, PF_PASS);
|
||||
}
|
||||
if (r->af) {
|
||||
if (r->af == AF_INET)
|
||||
|
@@ -677,9 +677,6 @@ S_vmtotal(size_t l2, void *p)
|
||||
}
|
||||
|
||||
#ifdef __amd64__
|
||||
#define efi_next_descriptor(ptr, size) \
|
||||
((struct efi_md *)(((uint8_t *) ptr) + size))
|
||||
|
||||
static int
|
||||
S_efi_map(size_t l2, void *p)
|
||||
{
|
||||
|
Reference in New Issue
Block a user