Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F168312314
D26409.id76940.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D26409.id76940.diff
View Options
Index: sbin/ping/ping.c
===================================================================
--- sbin/ping/ping.c
+++ sbin/ping/ping.c
@@ -155,6 +155,7 @@
#define F_TIME 0x100000
#define F_SWEEP 0x200000
#define F_WAITTIME 0x400000
+#define F_SO_VLAN_PCP 0x800000
/*
* MAX_DUP_CHK is the number of bits in received table, i.e. the maximum
@@ -247,7 +248,7 @@
u_long alarmtimeout;
long ltmp;
int almost_done, ch, df, hold, i, icmp_len, mib[4], preload;
- int ssend_errno, srecv_errno, tos, ttl;
+ int ssend_errno, srecv_errno, tos, ttl, pcp;
char ctrl[CMSG_SPACE(sizeof(struct timespec))];
char hnamebuf[MAXHOSTNAMELEN], snamebuf[MAXHOSTNAMELEN];
#ifdef IP_OPTIONS
@@ -295,11 +296,11 @@
err(EX_OSERR, "srecv socket");
}
- alarmtimeout = df = preload = tos = 0;
+ alarmtimeout = df = preload = tos = pcp = 0;
outpack = outpackhdr + sizeof(struct ip);
while ((ch = getopt(argc, argv,
- "Aac:DdfG:g:Hh:I:i:Ll:M:m:nop:QqRrS:s:T:t:vW:z:"
+ "Aac:DdfG:g:Hh:I:i:Ll:M:m:nop:QqRrS:s:T:t:vW:z:C:"
#ifdef IPSEC
#ifdef IPSEC_POLICY_IPSEC
"P:"
@@ -533,6 +534,13 @@
errx(EX_USAGE, "invalid TOS: `%s'", optarg);
tos = ltmp;
break;
+ case 'C':
+ options |= F_SO_VLAN_PCP;
+ ltmp = strtol(optarg, &ep, 0);
+ if (*ep || ep == optarg || ltmp > 7 || ltmp < -1)
+ errx(EX_USAGE, "invalid PCP: `%s'", optarg);
+ pcp = ltmp;
+ break;
default:
usage();
}
@@ -665,6 +673,10 @@
if (options & F_SO_DONTROUTE)
(void)setsockopt(ssend, SOL_SOCKET, SO_DONTROUTE, (char *)&hold,
sizeof(hold));
+ if (options & F_SO_VLAN_PCP) {
+ (void)setsockopt(ssend, SOL_SOCKET, SO_VLAN_PCP, (char *)&pcp,
+ sizeof(pcp));
+ }
#ifdef IPSEC
#ifdef IPSEC_POLICY_IPSEC
if (options & F_POLICY) {
@@ -1765,10 +1777,10 @@
"usage: ping [-AaDdfHnoQqRrv] [-c count] [-G sweepmaxsize] [-g sweepminsize]",
" [-h sweepincrsize] [-i wait] [-l preload] [-M mask | time] [-m ttl]",
" " SECOPT " [-p pattern] [-S src_addr] [-s packetsize] [-t timeout]",
-" [-W waittime] [-z tos] host",
+" [-W waittime] [-z tos] [-C pcp] host",
" ping [-AaDdfHLnoQqRrv] [-c count] [-I iface] [-i wait] [-l preload]",
" [-M mask | time] [-m ttl]" SECOPT " [-p pattern] [-S src_addr]",
" [-s packetsize] [-T ttl] [-t timeout] [-W waittime]",
-" [-z tos] mcast-group");
+" [-z tos] [-C pcp] mcast-group");
exit(EX_USAGE);
}
Index: sbin/ping6/ping6.c
===================================================================
--- sbin/ping6/ping6.c
+++ sbin/ping6/ping6.c
@@ -230,6 +230,7 @@
static u_int8_t nonce[8]; /* nonce field for node information */
static int hoplimit = -1; /* hoplimit */
static int tclass = -1; /* traffic class */
+static int pcp = -2; /* vlan priority code point */
static u_char *packet = NULL;
static cap_channel_t *capdns;
@@ -353,7 +354,7 @@
#endif /*IPSEC_POLICY_IPSEC*/
#endif
while ((ch = getopt(argc, argv,
- "k:b:c:DdfHe:m:I:i:l:unNop:qaAS:s:OvyYW:t:z:" ADDOPTS)) != -1) {
+ "k:b:c:DdfHe:m:I:i:l:unNop:qaAS:s:OvyYW:t:z:C:" ADDOPTS)) != -1) {
#undef ADDOPTS
switch (ch) {
case 'k':
@@ -594,6 +595,13 @@
errx(1,
"illegal traffic class -- %s", optarg);
break;
+ case 'C': /* vlan priority code point */
+ pcp = strtol(optarg, &e, 10);
+ if (*optarg == '\0' || *e != '\0')
+ errx(1, "illegal vlan pcp %s", optarg);
+ if (7 < pcp || pcp < -1)
+ errx(1, "illegal vlan pcp -- %s", optarg);
+ break;
#ifdef IPSEC
#ifdef IPSEC_POLICY_IPSEC
case 'P':
@@ -952,6 +960,12 @@
err(1, "setsockopt(IPV6_TCLASS)");
}
+ if (pcp != -2) {
+ if (setsockopt(ssend, SOL_SOCKET, SO_VLAN_PCP,
+ &pcp, sizeof(pcp)) == -1)
+ err(1, "setsockopt(SO_VLAN_PCP)");
+ }
+
if (argc > 1) { /* some intermediate addrs are specified */
int hops;
int rthdrlen;
Index: sys/kern/uipc_socket.c
===================================================================
--- sys/kern/uipc_socket.c
+++ sys/kern/uipc_socket.c
@@ -434,6 +434,7 @@
__func__, __LINE__, so));
so->so_vnet = vnet;
#endif
+ so->so_vlan_pcp = -1;
/* We shouldn't need the so_global_mtx */
if (hhook_run_socket(so, NULL, HHOOK_SOCKET_CREATE)) {
/* Do we need more comprehensive error returns? */
@@ -3171,6 +3172,21 @@
so->so_max_pacing_rate = val32;
break;
+ case SO_VLAN_PCP:
+ error = sooptcopyin(sopt, &optval, sizeof(optval),
+ sizeof(optval));
+ if (error)
+ goto bad;
+ if ((optval >= -1) && (optval <= 7)) {
+ SOCK_LOCK(so);
+ so->so_vlan_pcp = optval;
+ SOCK_UNLOCK(so);
+ } else {
+ error = EINVAL;
+ goto bad;
+ }
+ break;
+
default:
if (V_socket_hhh[HHOOK_SOCKET_OPT]->hhh_nhooks > 0)
error = hhook_run_socket(so, sopt,
@@ -3377,6 +3393,10 @@
optval = so->so_max_pacing_rate;
goto integer;
+ case SO_VLAN_PCP:
+ optval = so->so_vlan_pcp;
+ goto integer;
+
default:
if (V_socket_hhh[HHOOK_SOCKET_OPT]->hhh_nhooks > 0)
error = hhook_run_socket(so, sopt,
Index: sys/net/if_ethersubr.c
===================================================================
--- sys/net/if_ethersubr.c
+++ sys/net/if_ethersubr.c
@@ -1387,6 +1387,13 @@
}
}
+ /*
+ * If PCP is set in mbuf, use it
+ */
+ if ((*mp)->m_flags & M_VLANTAG) {
+ pcp = EVL_PRIOFTAG((*mp)->m_pkthdr.ether_vtag);
+ }
+
/*
* If underlying interface can do VLAN tag insertion itself,
* just pass the packet along. However, we need some way to
Index: sys/netinet/ip_output.c
===================================================================
--- sys/netinet/ip_output.c
+++ sys/netinet/ip_output.c
@@ -63,7 +63,9 @@
#include <net/if.h>
#include <net/if_var.h>
+#include <net/if_vlan_var.h>
#include <net/if_llatbl.h>
+#include <net/ethernet.h>
#include <net/netisr.h>
#include <net/pfil.h>
#include <net/route.h>
@@ -325,6 +327,7 @@
int hlen = sizeof (struct ip);
int mtu;
int error = 0;
+ int vlan_pcp = -1;
struct sockaddr_in *dst, sin;
const struct sockaddr_in *gw;
struct in_ifaddr *ia;
@@ -346,6 +349,11 @@
m->m_pkthdr.flowid = inp->inp_flowid;
M_HASHTYPE_SET(m, inp->inp_flowtype);
}
+ if (inp->inp_socket) {
+ vlan_pcp = inp->inp_socket->so_vlan_pcp;
+ KASSERT((vlan_pcp >= -1) && (vlan_pcp <= 7),
+ ("Invalid PCP values"));
+ }
#ifdef NUMA
m->m_pkthdr.numa_domain = inp->inp_numa_domain;
#endif
@@ -723,6 +731,10 @@
}
}
+ if (vlan_pcp > -1) {
+ EVL_APPLY_PRI(m, vlan_pcp);
+ }
+
/* IN_LOOPBACK must not appear on the wire - RFC1122. */
if (IN_LOOPBACK(ntohl(ip->ip_dst.s_addr)) ||
IN_LOOPBACK(ntohl(ip->ip_src.s_addr))) {
Index: sys/netinet6/ip6_output.c
===================================================================
--- sys/netinet6/ip6_output.c
+++ sys/netinet6/ip6_output.c
@@ -92,7 +92,9 @@
#include <net/if.h>
#include <net/if_var.h>
+#include <net/if_vlan_var.h>
#include <net/if_llatbl.h>
+#include <net/ethernet.h>
#include <net/netisr.h>
#include <net/route.h>
#include <net/route/nhop.h>
@@ -449,6 +451,7 @@
uint32_t fibnum;
struct m_tag *fwd_tag = NULL;
uint32_t id;
+ int vlan_pcp = -1;
NET_EPOCH_ASSERT();
@@ -460,6 +463,11 @@
m->m_pkthdr.flowid = inp->inp_flowid;
M_HASHTYPE_SET(m, inp->inp_flowtype);
}
+ if (inp->inp_socket) {
+ vlan_pcp = inp->inp_socket->so_vlan_pcp;
+ KASSERT((vlan_pcp >= -1) && (vlan_pcp <= 7),
+ ("Invalid PCP values"));
+ }
#ifdef NUMA
m->m_pkthdr.numa_domain = inp->inp_numa_domain;
#endif
@@ -1098,6 +1106,10 @@
}
passout:
+ if (vlan_pcp > -1) {
+ EVL_APPLY_PRI(m, vlan_pcp);
+ }
+
/*
* Send the packet to the outgoing interface.
* If necessary, do IPv6 fragmentation before sending.
@@ -1264,6 +1276,9 @@
counter_u64_add(ia->ia_ifa.ifa_obytes,
m->m_pkthdr.len);
}
+ if (vlan_pcp > -1) {
+ EVL_APPLY_PRI(m, vlan_pcp);
+ }
error = ip6_output_send(inp, ifp, origifp, m, dst, ro,
true);
} else
Index: sys/sys/socket.h
===================================================================
--- sys/sys/socket.h
+++ sys/sys/socket.h
@@ -172,6 +172,7 @@
#define SO_TS_CLOCK 0x1017 /* clock type used for SO_TIMESTAMP */
#define SO_MAX_PACING_RATE 0x1018 /* socket's max TX pacing rate (Linux name) */
#define SO_DOMAIN 0x1019 /* get socket domain */
+#define SO_VLAN_PCP 0x1020 /* VLAN PCP priority */
#endif
#if __BSD_VISIBLE
Index: sys/sys/socketvar.h
===================================================================
--- sys/sys/socketvar.h
+++ sys/sys/socketvar.h
@@ -120,6 +120,7 @@
int so_ts_clock; /* type of the clock used for timestamps */
uint32_t so_max_pacing_rate; /* (f) TX rate limit in bytes/s */
+ int so_vlan_pcp; /* vlan pcp */
union {
/* Regular (data flow) socket. */
struct {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Aug 28, 2:11 PM (7 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37458567
Default Alt Text
D26409.id76940.diff (8 KB)
Attached To
Mode
D26409: Add IP(V6)_VLAN_PCP to adjust 802.1 priority per-flow.
Attached
Detach File
Event Timeline
Log In to Comment