Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netpfil/ipfw/dn_sched_fq_pie.c
Show First 20 Lines • Show All 786 Lines • ▼ Show 20 Lines | |||||
fq_pie_classify_flow(struct mbuf *m, uint16_t fcount, struct fq_pie_si *si) | fq_pie_classify_flow(struct mbuf *m, uint16_t fcount, struct fq_pie_si *si) | ||||
{ | { | ||||
struct ip *ip; | struct ip *ip; | ||||
struct tcphdr *th; | struct tcphdr *th; | ||||
struct udphdr *uh; | struct udphdr *uh; | ||||
uint8_t tuple[41]; | uint8_t tuple[41]; | ||||
uint16_t hash=0; | uint16_t hash=0; | ||||
ip = (struct ip *)mtodo(m, dn_tag_get(m)->iphdr_off); | |||||
//#ifdef INET6 | //#ifdef INET6 | ||||
struct ip6_hdr *ip6; | struct ip6_hdr *ip6; | ||||
int isip6; | int isip6; | ||||
isip6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0; | isip6 = (ip->ip_v == 6); | ||||
if(isip6) { | if(isip6) { | ||||
ip6 = mtod(m, struct ip6_hdr *); | ip6 = (struct ip6_hdr *)ip; | ||||
*((uint8_t *) &tuple[0]) = ip6->ip6_nxt; | *((uint8_t *) &tuple[0]) = ip6->ip6_nxt; | ||||
*((uint32_t *) &tuple[1]) = si->perturbation; | *((uint32_t *) &tuple[1]) = si->perturbation; | ||||
memcpy(&tuple[5], ip6->ip6_src.s6_addr, 16); | memcpy(&tuple[5], ip6->ip6_src.s6_addr, 16); | ||||
memcpy(&tuple[21], ip6->ip6_dst.s6_addr, 16); | memcpy(&tuple[21], ip6->ip6_dst.s6_addr, 16); | ||||
switch (ip6->ip6_nxt) { | switch (ip6->ip6_nxt) { | ||||
case IPPROTO_TCP: | case IPPROTO_TCP: | ||||
th = (struct tcphdr *)(ip6 + 1); | th = (struct tcphdr *)(ip6 + 1); | ||||
Show All 11 Lines | if(isip6) { | ||||
} | } | ||||
hash = jenkins_hash(tuple, 41, HASHINIT) % fcount; | hash = jenkins_hash(tuple, 41, HASHINIT) % fcount; | ||||
return hash; | return hash; | ||||
} | } | ||||
//#endif | //#endif | ||||
/* IPv4 */ | /* IPv4 */ | ||||
ip = mtod(m, struct ip *); | |||||
*((uint8_t *) &tuple[0]) = ip->ip_p; | *((uint8_t *) &tuple[0]) = ip->ip_p; | ||||
*((uint32_t *) &tuple[1]) = si->perturbation; | *((uint32_t *) &tuple[1]) = si->perturbation; | ||||
*((uint32_t *) &tuple[5]) = ip->ip_src.s_addr; | *((uint32_t *) &tuple[5]) = ip->ip_src.s_addr; | ||||
*((uint32_t *) &tuple[9]) = ip->ip_dst.s_addr; | *((uint32_t *) &tuple[9]) = ip->ip_dst.s_addr; | ||||
switch (ip->ip_p) { | switch (ip->ip_p) { | ||||
case IPPROTO_TCP: | case IPPROTO_TCP: | ||||
th = (struct tcphdr *)(ip + 1); | th = (struct tcphdr *)(ip + 1); | ||||
▲ Show 20 Lines • Show All 398 Lines • Show Last 20 Lines |