Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/ipfw/ip_dn_io.c
Show First 20 Lines • Show All 835 Lines • ▼ Show 20 Lines | mtag = m_tag_get(PACKET_TAG_DUMMYNET, | ||||
sizeof(*dt), M_NOWAIT | M_ZERO); | sizeof(*dt), M_NOWAIT | M_ZERO); | ||||
if (mtag == NULL) | if (mtag == NULL) | ||||
return 1; /* Cannot allocate packet header. */ | return 1; /* Cannot allocate packet header. */ | ||||
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->flags & IPFW_ARGS_OUT ? fwa->ifp : NULL; | ||||
/* 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; | 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 | ||||
* determine the queue and scheduler instances. | * determine the queue and scheduler instances. | ||||
* | |||||
* dir where shall we send the packet after dummynet. | |||||
* *m0 the mbuf with the packet | |||||
* ifp the 'ifp' parameter from the caller. | |||||
* NULL in ip_input, destination interface in ip_output, | |||||
*/ | */ | ||||
int | int | ||||
dummynet_io(struct mbuf **m0, int dir, struct ip_fw_args *fwa) | dummynet_io(struct mbuf **m0, struct ip_fw_args *fwa) | ||||
{ | { | ||||
struct mbuf *m = *m0; | struct mbuf *m = *m0; | ||||
struct dn_fsk *fs = NULL; | struct dn_fsk *fs = NULL; | ||||
struct dn_sch_inst *si; | struct dn_sch_inst *si; | ||||
struct dn_queue *q = NULL; /* default */ | struct dn_queue *q = NULL; /* default */ | ||||
int fs_id, dir; | |||||
int fs_id = (fwa->rule.info & IPFW_INFO_MASK) + | fs_id = (fwa->rule.info & IPFW_INFO_MASK) + | ||||
((fwa->rule.info & IPFW_IS_PIPE) ? 2*DN_MAX_ID : 0); | ((fwa->rule.info & IPFW_IS_PIPE) ? 2*DN_MAX_ID : 0); | ||||
/* XXXGL: convert args to dir */ | |||||
if (fwa->flags & IPFW_ARGS_IN) | |||||
dir = DIR_IN; | |||||
else | |||||
dir = DIR_OUT; | |||||
if (fwa->flags & IPFW_ARGS_ETHER) | |||||
dir |= PROTO_LAYER2; | |||||
else if (fwa->flags & IPFW_ARGS_IP6) | |||||
dir |= PROTO_IPV6; | |||||
DN_BH_WLOCK(); | DN_BH_WLOCK(); | ||||
io_pkt++; | io_pkt++; | ||||
/* we could actually tag outside the lock, but who cares... */ | /* we could actually tag outside the lock, but who cares... */ | ||||
if (tag_mbuf(m, dir, fwa)) | if (tag_mbuf(m, dir, fwa)) | ||||
goto dropit; | goto dropit; | ||||
if (dn_cfg.busy) { | if (dn_cfg.busy) { | ||||
/* if the upper half is busy doing something expensive, | /* if the upper half is busy doing something expensive, | ||||
* lets queue the packet and move forward | * lets queue the packet and move forward | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |