diff options
author | 2016-06-10 20:33:29 +0000 | |
---|---|---|
committer | 2016-06-10 20:33:29 +0000 | |
commit | a5e12720217847441cb726e03cdcfe69b447c4ac (patch) | |
tree | 66db6c8b4c6ef4516ef5325e441150a0bda968ed | |
parent | The power management timer has been made optional in ACPI 5.0A, so don't (diff) | |
download | wireguard-openbsd-a5e12720217847441cb726e03cdcfe69b447c4ac.tar.xz wireguard-openbsd-a5e12720217847441cb726e03cdcfe69b447c4ac.zip |
Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.
"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).
ok sthen@ mikeb@
-rw-r--r-- | sbin/ifconfig/ifconfig.8 | 8 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 44 | ||||
-rw-r--r-- | sys/net/bpf.c | 3 | ||||
-rw-r--r-- | sys/net/if.c | 15 | ||||
-rw-r--r-- | sys/net/if.h | 3 | ||||
-rw-r--r-- | sys/net/if_var.h | 3 | ||||
-rw-r--r-- | sys/netinet/if_ether.c | 4 | ||||
-rw-r--r-- | sys/sys/sockio.h | 5 |
8 files changed, 70 insertions, 15 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index c301a904e09..af54b29f477 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.267 2016/04/06 10:07:14 jsg Exp $ +.\" $OpenBSD: ifconfig.8,v 1.268 2016/06/10 20:33:29 vgross Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -31,7 +31,7 @@ .\" .\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94 .\" -.Dd $Mdocdate: April 6 2016 $ +.Dd $Mdocdate: June 10 2016 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -327,6 +327,10 @@ Disable special processing at the link level with the specified interface. Change the link layer address (MAC address) of the interface. This should be specified as six colon-separated hex values, or can be chosen randomly. +.It Cm llprio Ar prio +Set the priority for link layer communications +.Pf ( Xr arp 4 , +.Xr bpf 4 ) . .It Cm media Op Ar type Set the media type of the interface to .Ar type . diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index c30ced51a54..1e39ec90894 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.322 2016/05/03 17:52:33 jca Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.323 2016/06/10 20:33:29 vgross Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -135,6 +135,7 @@ char name[IFNAMSIZ]; int flags, xflags, setaddr, setipdst, doalias; u_long metric, mtu; int rdomainid; +int llprio; int clearaddr, s; int newaddr = 0; int af = AF_INET; @@ -157,6 +158,7 @@ void addaf(const char *, int); void removeaf(const char *, int); void setifbroadaddr(const char *, int); void setifmtu(const char *, int); +void setifllprio(const char *, int); void setifnwid(const char *, int); void setifbssid(const char *, int); void setifnwkey(const char *, int); @@ -521,6 +523,7 @@ const struct cmd { { "instance", NEXTARG, A_MEDIAINST, setmediainst }, { "inst", NEXTARG, A_MEDIAINST, setmediainst }, { "lladdr", NEXTARG, 0, setiflladdr }, + { "llprio", NEXTARG, 0, setifllprio }, { NULL, /*src*/ 0, 0, setifaddr }, { NULL, /*dst*/ 0, 0, setifdstaddr }, { NULL, /*illegal*/0, 0, NULL }, @@ -854,6 +857,11 @@ getinfo(struct ifreq *ifr, int create) else rdomainid = ifr->ifr_rdomainid; #endif + if (ioctl(s, SIOCGIFLLPRIO, (caddr_t)ifr) < 0) + llprio = 0; + else + llprio = ifr->ifr_llprio; + return (0); } @@ -1411,6 +1419,21 @@ setifmtu(const char *val, int d) /* ARGSUSED */ void +setifllprio(const char *val, int d) +{ + const char *errmsg = NULL; + + (void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); + + ifr.ifr_mtu = strtonum(val, 0, UCHAR_MAX, &errmsg); + if (errmsg) + errx(1, "mtu %s: %s", val, errmsg); + if (ioctl(s, SIOCSIFLLPRIO, (caddr_t)&ifr) < 0) + warn("SIOCSIFLLPRIO"); +} + +/* ARGSUSED */ +void setifgroup(const char *group_name, int dummy) { struct ifgroupreq ifgr; @@ -2885,6 +2908,8 @@ status(int link, struct sockaddr_dl *sdl, int ls) #endif uint64_t *media_list; int i; + char sep; + printf("%s: ", name); printb("flags", flags | (xflags << 16), IFFBITS); @@ -2904,6 +2929,7 @@ status(int link, struct sockaddr_dl *sdl, int ls) (void)printf("\tlladdr %s\n", ether_ntoa( (struct ether_addr *)LLADDR(sdl))); + sep = '\t'; #ifndef SMALL (void) memset(&ifrdesc, 0, sizeof(ifrdesc)); (void) strlcpy(ifrdesc.ifr_name, name, sizeof(ifrdesc.ifr_name)); @@ -2912,14 +2938,18 @@ status(int link, struct sockaddr_dl *sdl, int ls) strlen(ifrdesc.ifr_data)) printf("\tdescription: %s\n", ifrdesc.ifr_data); - if (sdl != NULL) - printf("\tindex %u", sdl->sdl_index); + if (sdl != NULL) { + printf("%cindex %u", sep, sdl->sdl_index); + sep = ' '; + } if (!is_bridge(name) && ioctl(s, SIOCGIFPRIORITY, &ifrdesc) == 0) { - printf("%cpriority %d\n", (sdl != NULL) ? ' ' : '\t', - ifrdesc.ifr_metric); - } else if (sdl != NULL) { - putchar('\n'); + printf("%cpriority %d", sep, ifrdesc.ifr_metric); + sep = ' '; } +#endif + printf("%cllprio %d\n", sep, llprio); + +#ifndef SMALL (void) memset(&ikardesc, 0, sizeof(ikardesc)); (void) strlcpy(ikardesc.ikar_name, name, sizeof(ikardesc.ikar_name)); if (ioctl(s, SIOCGETKALIVE, &ikardesc) == 0 && diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 31b6ed0c5c2..a792c34b3cd 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.141 2016/05/18 03:46:03 dlg Exp $ */ +/* $OpenBSD: bpf.c,v 1.142 2016/06/10 20:33:29 vgross Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -561,6 +561,7 @@ bpfwrite(dev_t dev, struct uio *uio, int ioflag) } m->m_pkthdr.ph_rtableid = ifp->if_rdomain; + m->m_pkthdr.pf.prio = ifp->if_llprio; if (d->bd_hdrcmplt && dst.ss_family == AF_UNSPEC) dst.ss_family = pseudo_AF_HDRCMPLT; diff --git a/sys/net/if.c b/sys/net/if.c index 9b53bf17ebf..c04975c0f80 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.433 2016/05/18 03:46:03 dlg Exp $ */ +/* $OpenBSD: if.c,v 1.434 2016/06/10 20:33:29 vgross Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -536,6 +536,7 @@ if_attach_common(struct ifnet *ifp) M_TEMP, M_WAITOK|M_ZERO); ifp->if_linkstatetask = malloc(sizeof(*ifp->if_linkstatetask), M_TEMP, M_WAITOK|M_ZERO); + ifp->if_llprio = IFQ_DEFPRIO; SRPL_INIT(&ifp->if_inputs); } @@ -1988,6 +1989,18 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) ifnewlladdr(ifp); break; + case SIOCGIFLLPRIO: + ifr->ifr_llprio = ifp->if_llprio; + break; + + case SIOCSIFLLPRIO: + if ((error = suser(p, 0))) + return (error); + if (ifr->ifr_llprio > UCHAR_MAX) + return (EINVAL); + ifp->if_llprio = ifr->ifr_llprio; + break; + default: if (so->so_proto == 0) return (EOPNOTSUPP); diff --git a/sys/net/if.h b/sys/net/if.h index 3d3569d960e..3022b38482b 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.176 2016/03/02 00:00:16 dlg Exp $ */ +/* $OpenBSD: if.h,v 1.177 2016/06/10 20:33:29 vgross Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -378,6 +378,7 @@ struct ifreq { #define ifr_ttl ifr_ifru.ifru_metric /* tunnel TTL (overload) */ #define ifr_data ifr_ifru.ifru_data /* for use by interface */ #define ifr_index ifr_ifru.ifru_index /* interface index */ +#define ifr_llprio ifr_ifru.ifru_metric /* link layer priority */ }; struct ifaliasreq { diff --git a/sys/net/if_var.h b/sys/net/if_var.h index d0f4e342c39..2ef76ad35ba 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_var.h,v 1.71 2016/04/15 05:05:21 dlg Exp $ */ +/* $OpenBSD: if_var.h,v 1.72 2016/06/10 20:33:29 vgross Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -131,6 +131,7 @@ struct ifnet { /* and the entries */ char if_description[IFDESCRSIZE]; /* interface description */ u_short if_rtlabelid; /* next route label */ u_int8_t if_priority; + u_int8_t if_llprio; /* link layer priority */ struct timeout *if_slowtimo; /* watchdog timeout */ struct task *if_watchdogtask; /* watchdog task */ struct task *if_linkstatetask; /* task to do route updates */ diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 37f932f3fe9..54abf79ae6b 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.213 2016/06/06 07:07:11 mpi Exp $ */ +/* $OpenBSD: if_ether.c,v 1.214 2016/06/10 20:33:29 vgross Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -235,6 +235,7 @@ arprequest(struct ifnet *ifp, u_int32_t *sip, u_int32_t *tip, u_int8_t *enaddr) m->m_len = sizeof(*ea); m->m_pkthdr.len = sizeof(*ea); m->m_pkthdr.ph_rtableid = ifp->if_rdomain; + m->m_pkthdr.pf.prio = ifp->if_llprio; MH_ALIGN(m, sizeof(*ea)); ea = mtod(m, struct ether_arp *); eh = (struct ether_header *)sa.sa_data; @@ -832,6 +833,7 @@ revarprequest(struct ifnet *ifp) return; m->m_len = sizeof(*ea); m->m_pkthdr.len = sizeof(*ea); + m->m_pkthdr.pf.prio = ifp->if_llprio; MH_ALIGN(m, sizeof(*ea)); ea = mtod(m, struct ether_arp *); eh = (struct ether_header *)sa.sa_data; diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h index 1d6d35a6ddb..52d5ff578b6 100644 --- a/sys/sys/sockio.h +++ b/sys/sys/sockio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sockio.h,v 1.64 2016/05/31 22:35:02 tedu Exp $ */ +/* $OpenBSD: sockio.h,v 1.65 2016/06/10 20:33:29 vgross Exp $ */ /* $NetBSD: sockio.h,v 1.5 1995/08/23 00:40:47 thorpej Exp $ */ /*- @@ -202,6 +202,9 @@ #define SIOCGIFPARENT _IOWR('i', 179, struct if_parent) /* get parent if */ #define SIOCDIFPARENT _IOW('i', 180, struct ifreq) /* del parent if */ +#define SIOCSIFLLPRIO _IOW('i', 181, struct ifreq) /* set ifnet llprio */ +#define SIOCGIFLLPRIO _IOWR('i', 182, struct ifreq) /* get ifnet llprio */ + #define SIOCSVH _IOWR('i', 245, struct ifreq) /* set carp param */ #define SIOCGVH _IOWR('i', 246, struct ifreq) /* get carp param */ |