-/* $OpenBSD: kroute.c,v 1.98 2017/06/28 15:45:32 krw Exp $ */
+/* $OpenBSD: kroute.c,v 1.99 2017/06/28 16:31:52 krw Exp $ */
/*
* Copyright 2012 Kenneth R Westerback <krw@openbsd.org>
}
void
-priv_flush_routes(struct interface_info *ifi)
+priv_flush_routes(char *name, int rdomain)
{
char ifname[IF_NAMESIZE];
struct sockaddr *rti_info[RTAX_MAX];
mib[3] = AF_INET;
mib[4] = NET_RT_FLAGS;
mib[5] = RTF_GATEWAY;
- mib[6] = ifi->rdomain;
+ mib[6] = rdomain;
while (1) {
if (sysctl(mib, 7, NULL, &needed, NULL, 0) == -1) {
if (if_indextoname(rtm->rtm_index, ifname) &&
sa_in &&
sa_in->sin_addr.s_addr == INADDR_ANY &&
- rtm->rtm_tableid == ifi->rdomain &&
- strcmp(ifi->name, ifname) == 0)
+ rtm->rtm_tableid == rdomain &&
+ strcmp(name, ifname) == 0)
delete_route(s, rtm);
break;
default:
}
void
-priv_add_route(struct interface_info *ifi, struct imsg_add_route *imsg)
+priv_add_route(int rdomain, struct imsg_add_route *imsg)
{
char destbuf[INET_ADDRSTRLEN], gatewaybuf[INET_ADDRSTRLEN];
char maskbuf[INET_ADDRSTRLEN], ifabuf[INET_ADDRSTRLEN];
rtm.rtm_version = RTM_VERSION;
rtm.rtm_type = RTM_ADD;
- rtm.rtm_tableid = ifi->rdomain;
+ rtm.rtm_tableid = rdomain;
rtm.rtm_priority = RTP_NONE;
rtm.rtm_msglen = sizeof(rtm);
rtm.rtm_addrs = imsg->addrs;
}
void
-priv_delete_address(struct interface_info *ifi,
- struct imsg_delete_address *imsg)
+priv_delete_address(char *name, struct imsg_delete_address *imsg)
{
struct ifaliasreq ifaliasreq;
struct sockaddr_in *in;
fatal("socket open failed");
memset(&ifaliasreq, 0, sizeof(ifaliasreq));
- strncpy(ifaliasreq.ifra_name, ifi->name, sizeof(ifaliasreq.ifra_name));
+ strncpy(ifaliasreq.ifra_name, name, sizeof(ifaliasreq.ifra_name));
in = (struct sockaddr_in *)&ifaliasreq.ifra_addr;
in->sin_family = AF_INET;
}
void
-priv_set_interface_mtu(struct interface_info *ifi,
- struct imsg_set_interface_mtu *imsg)
+priv_set_interface_mtu(char *name, struct imsg_set_interface_mtu *imsg)
{
struct ifreq ifr;
int s;
memset(&ifr, 0, sizeof(ifr));
- strlcpy(ifr.ifr_name, ifi->name, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_mtu = imsg->mtu;
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
}
void
-priv_add_address(struct interface_info *ifi, struct imsg_add_address *imsg)
+priv_add_address(char *name, struct imsg_add_address *imsg)
{
struct ifaliasreq ifaliasreq;
struct sockaddr_in *in;
fatal("socket open failed");
memset(&ifaliasreq, 0, sizeof(ifaliasreq));
- strncpy(ifaliasreq.ifra_name, ifi->name, sizeof(ifaliasreq.ifra_name));
+ strncpy(ifaliasreq.ifra_name, name, sizeof(ifaliasreq.ifra_name));
/* The actual address in ifra_addr. */
in = (struct sockaddr_in *)&ifaliasreq.ifra_addr;
}
void
-priv_write_resolv_conf(struct interface_info *ifi, u_int8_t *contents, size_t sz)
+priv_write_resolv_conf(int rdomain, u_int8_t *contents, size_t sz)
{
const char *path = "/etc/resolv.conf";
ssize_t n;
int fd;
- if (!resolv_conf_priority(ifi->rdomain))
+ if (!resolv_conf_priority(rdomain))
return;
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC,
* create /etc/resolv.conf
*/
char *
-resolv_conf_contents(struct interface_info *ifi,
+resolv_conf_contents(char *name,
struct option_data *domainname, struct option_data *nameservers,
struct option_data *domainsearch)
{
return (NULL);
}
- rslt = asprintf(&courtesy, "# Generated by %s dhclient\n", ifi->name);
+ rslt = asprintf(&courtesy, "# Generated by %s dhclient\n", name);
if (rslt == -1)
fatalx("no memory for courtesy line");
len += strlen(courtesy);
-/* $OpenBSD: privsep.c,v 1.51 2017/06/28 14:35:43 krw Exp $ */
+/* $OpenBSD: privsep.c,v 1.52 2017/06/28 16:31:52 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
sizeof(struct imsg_delete_address))
log_warnx("bad IMSG_DELETE_ADDRESS");
else
- priv_delete_address(ifi, imsg.data);
+ priv_delete_address(ifi->name, imsg.data);
break;
case IMSG_ADD_ADDRESS:
sizeof(struct imsg_add_address))
log_warnx("bad IMSG_ADD_ADDRESS");
else
- priv_add_address(ifi, imsg.data);
+ priv_add_address(ifi->name, imsg.data);
break;
case IMSG_FLUSH_ROUTES:
if (imsg.hdr.len != IMSG_HEADER_SIZE)
log_warnx("bad IMSG_FLUSH_ROUTES");
else
- priv_flush_routes(ifi);
+ priv_flush_routes(ifi->name, ifi->rdomain);
break;
case IMSG_ADD_ROUTE:
sizeof(struct imsg_add_route))
log_warnx("bad IMSG_ADD_ROUTE");
else
- priv_add_route(ifi, imsg.data);
+ priv_add_route(ifi->rdomain, imsg.data);
break;
case IMSG_SET_INTERFACE_MTU:
sizeof(struct imsg_set_interface_mtu))
log_warnx("bad IMSG_SET_INTERFACE_MTU");
else
- priv_set_interface_mtu(ifi, imsg.data);
+ priv_set_interface_mtu(ifi->name, imsg.data);
break;
case IMSG_WRITE_RESOLV_CONF:
if (imsg.hdr.len <= IMSG_HEADER_SIZE)
log_warnx("short IMSG_WRITE_RESOLV_CONF");
else
- priv_write_resolv_conf(ifi, imsg.data,
+ priv_write_resolv_conf(ifi->rdomain, imsg.data,
imsg.hdr.len - IMSG_HEADER_SIZE);
break;
-/* $OpenBSD: privsep.h,v 1.39 2017/06/28 14:35:43 krw Exp $ */
+/* $OpenBSD: privsep.h,v 1.40 2017/06/28 16:31:52 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
void add_default_route(struct in_addr, struct in_addr);
void add_static_routes(struct option_data *, struct in_addr);
void add_classless_static_routes(struct option_data *, struct in_addr);
-void priv_add_route(struct interface_info *, struct imsg_add_route *);
-void priv_flush_routes(struct interface_info *);
+void priv_add_route(int, struct imsg_add_route *);
+void priv_flush_routes(char *, int);
-char *resolv_conf_contents(struct interface_info *ifi, struct option_data *,
- struct option_data *, struct option_data *);
+char *resolv_conf_contents(char *, struct option_data *,
+ struct option_data *, struct option_data *);
void write_resolv_conf(u_int8_t *, size_t);
-void priv_write_resolv_conf(struct interface_info *, u_int8_t *, size_t);
+void priv_write_resolv_conf(int, u_int8_t *, size_t);
-void priv_delete_address(struct interface_info *,
- struct imsg_delete_address *);
-void priv_add_address(struct interface_info *, struct imsg_add_address *);
+void priv_delete_address(char *, struct imsg_delete_address *);
+void priv_add_address(char *, struct imsg_add_address *);
-void priv_set_interface_mtu(struct interface_info *,
- struct imsg_set_interface_mtu *);
+void priv_set_interface_mtu(char *, struct imsg_set_interface_mtu *);