Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netpfil/ipfw/ip_dn_io.c
Show First 20 Lines • Show All 231 Lines • ▼ Show 20 Lines | |||||
#undef DC | #undef DC | ||||
SYSEND | SYSEND | ||||
#endif | #endif | ||||
static void dummynet_send(struct mbuf *); | static void dummynet_send(struct mbuf *); | ||||
/* | /* | ||||
* Packets processed by dummynet have an mbuf tag associated with | |||||
* them that carries their dummynet state. | |||||
* Outside dummynet, only the 'rule' field is relevant, and it must | |||||
* be at the beginning of the structure. | |||||
*/ | |||||
struct dn_pkt_tag { | |||||
struct ipfw_rule_ref rule; /* matching rule */ | |||||
/* second part, dummynet specific */ | |||||
int dn_dir; /* action when packet comes out.*/ | |||||
/* see ip_fw_private.h */ | |||||
uint64_t output_time; /* when the pkt is due for delivery*/ | |||||
struct ifnet *ifp; /* interface, for ip_output */ | |||||
struct _ip6dn_args ip6opt; /* XXX ipv6 options */ | |||||
}; | |||||
/* | |||||
* Return the mbuf tag holding the dummynet state (it should | * Return the mbuf tag holding the dummynet state (it should | ||||
* be the first one on the list). | * be the first one on the list). | ||||
*/ | */ | ||||
static struct dn_pkt_tag * | struct dn_pkt_tag * | ||||
dn_tag_get(struct mbuf *m) | dn_tag_get(struct mbuf *m) | ||||
{ | { | ||||
struct m_tag *mtag = m_tag_first(m); | struct m_tag *mtag = m_tag_first(m); | ||||
#ifdef NEW_AQM | #ifdef NEW_AQM | ||||
/* XXX: to skip ts m_tag. For Debugging only*/ | /* XXX: to skip ts m_tag. For Debugging only*/ | ||||
if (mtag != NULL && mtag->m_tag_id == DN_AQM_MTAG_TS) { | if (mtag != NULL && mtag->m_tag_id == DN_AQM_MTAG_TS) { | ||||
m_tag_delete(m,mtag); | m_tag_delete(m,mtag); | ||||
mtag = m_tag_first(m); | mtag = m_tag_first(m); | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
#ifndef NEW_AQM | #ifndef NEW_AQM | ||||
static | static | ||||
#endif | #endif | ||||
int | int | ||||
ecn_mark(struct mbuf* m) | ecn_mark(struct mbuf* m) | ||||
{ | { | ||||
struct ip *ip; | struct ip *ip; | ||||
ip = mtod(m, struct ip *); | ip = (struct ip *)mtodo(m, dn_tag_get(m)->iphdr_off); | ||||
switch (ip->ip_v) { | switch (ip->ip_v) { | ||||
case IPVERSION: | case IPVERSION: | ||||
{ | { | ||||
uint16_t old; | uint16_t old; | ||||
if ((ip->ip_tos & IPTOS_ECN_MASK) == IPTOS_ECN_NOTECT) | if ((ip->ip_tos & IPTOS_ECN_MASK) == IPTOS_ECN_NOTECT) | ||||
return (0); /* not-ECT */ | return (0); /* not-ECT */ | ||||
if ((ip->ip_tos & IPTOS_ECN_MASK) == IPTOS_ECN_CE) | if ((ip->ip_tos & IPTOS_ECN_MASK) == IPTOS_ECN_CE) | ||||
return (1); /* already marked */ | return (1); /* already marked */ | ||||
/* | /* | ||||
* ecn-capable but not marked, | * ecn-capable but not marked, | ||||
* mark CE and update checksum | * mark CE and update checksum | ||||
*/ | */ | ||||
old = *(uint16_t *)ip; | old = *(uint16_t *)ip; | ||||
ip->ip_tos |= IPTOS_ECN_CE; | ip->ip_tos |= IPTOS_ECN_CE; | ||||
ip->ip_sum = cksum_adjust(ip->ip_sum, old, *(uint16_t *)ip); | ip->ip_sum = cksum_adjust(ip->ip_sum, old, *(uint16_t *)ip); | ||||
return (1); | return (1); | ||||
} | } | ||||
#ifdef INET6 | #ifdef INET6 | ||||
case (IPV6_VERSION >> 4): | case (IPV6_VERSION >> 4): | ||||
{ | { | ||||
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); | struct ip6_hdr *ip6 = (struct ip6_hdr *)ip; | ||||
u_int32_t flowlabel; | u_int32_t flowlabel; | ||||
flowlabel = ntohl(ip6->ip6_flow); | flowlabel = ntohl(ip6->ip6_flow); | ||||
if ((flowlabel >> 28) != 6) | if ((flowlabel >> 28) != 6) | ||||
return (0); /* version mismatch! */ | return (0); /* version mismatch! */ | ||||
if ((flowlabel & (IPTOS_ECN_MASK << 20)) == | if ((flowlabel & (IPTOS_ECN_MASK << 20)) == | ||||
(IPTOS_ECN_NOTECT << 20)) | (IPTOS_ECN_NOTECT << 20)) | ||||
return (0); /* not-ECT */ | return (0); /* not-ECT */ | ||||
▲ Show 20 Lines • Show All 370 Lines • ▼ Show 20 Lines | tag_mbuf(struct mbuf *m, int dir, struct ip_fw_args *fwa) | ||||
m_tag_prepend(m, mtag); /* Attach to mbuf chain. */ | m_tag_prepend(m, mtag); /* Attach to mbuf chain. */ | ||||
dt = (struct dn_pkt_tag *)(mtag + 1); | dt = (struct dn_pkt_tag *)(mtag + 1); | ||||
dt->rule = fwa->rule; | dt->rule = fwa->rule; | ||||
dt->rule.info &= IPFW_ONEPASS; /* only keep this info */ | dt->rule.info &= IPFW_ONEPASS; /* only keep this info */ | ||||
dt->dn_dir = dir; | dt->dn_dir = dir; | ||||
dt->ifp = fwa->oif; | dt->ifp = fwa->oif; | ||||
/* dt->output tame is updated as we move through */ | /* dt->output tame is updated as we move through */ | ||||
dt->output_time = dn_cfg.curr_time; | dt->output_time = dn_cfg.curr_time; | ||||
dt->iphdr_off = (dir & PROTO_LAYER2) ? ETHER_HDR_LEN : 0; | |||||
return 0; | return 0; | ||||
} | } | ||||
/* | /* | ||||
* dummynet hook for packets. | * dummynet hook for packets. | ||||
* We use the argument to locate the flowset fs and the sched_set sch | * We use the argument to locate the flowset fs and the sched_set sch | ||||
* associated to it. The we apply flow_mask and sched_mask to | * associated to it. The we apply flow_mask and sched_mask to | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |