--- zzzz-none-000/linux-2.6.28.10/net/ipv4/ip_output.c 2009-05-02 18:54:43.000000000 +0000 +++ puma5-6360-529/linux-2.6.28.10/net/ipv4/ip_output.c 2011-05-09 17:02:20.000000000 +0000 @@ -80,6 +80,16 @@ #include #include +#if defined(CONFIG_IFX_PPA_API) || defined(CONFIG_IFX_PPA_API_MODULE) + #include +#endif + +#if defined(CONFIG_FUSIV_KERNEL_AP_2_AP) || defined(CONFIG_FUSIV_KERNEL_AP_2_AP_MODULE) +#include +#include +#include +#endif + int sysctl_ip_default_ttl __read_mostly = IPDEFTTL; /* Generate a checksum for an outgoing IP datagram. */ @@ -201,6 +211,32 @@ skb = skb2; } +#if defined(CONFIG_IFX_PPA_API) || defined(CONFIG_IFX_PPA_API_MODULE) + if ( ppa_hook_session_add_fn != NULL ) + { +#ifdef CONFIG_NF_CONNTRACK + struct nf_conn *ct; +#else + struct ip_conntrack *ct; +#endif + + enum ip_conntrack_info ctinfo; + uint32_t flags; + + #ifdef CONFIG_NF_CONNTRACK + ct = nf_ct_get(skb, &ctinfo); + #else + ct = ip_conntrack_get(skb, &ctinfo); + #endif + + flags = 0; // post routing + flags |= CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL ? PPA_F_SESSION_ORG_DIR : PPA_F_SESSION_REPLY_DIR; + +/*--- int32_t (*ppa_hook_session_add_fn)(PPA_BUF *, PPA_SESSION *, uint32_t) = NULL; ---*/ + ppa_hook_session_add_fn(skb, ct, flags); + } +#endif + if (dst->hh) return neigh_hh_output(dst->hh, skb); else if (dst->neighbour) @@ -335,6 +371,7 @@ { struct flowi fl = { .oif = sk->sk_bound_dev_if, + .mark = sk->sk_mark, .nl_u = { .ip4_u = { .daddr = daddr, .saddr = inet->saddr, @@ -412,6 +449,10 @@ #ifdef CONFIG_NET_SCHED to->tc_index = from->tc_index; #endif +#ifdef CONFIG_AVM_PA + memcpy(&to->avm_pa.pktinfo, &from->avm_pa.pktinfo, + sizeof(from->avm_pa.pktinfo)); +#endif nf_copy(to, from); #if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \ defined(CONFIG_NETFILTER_XT_TARGET_TRACE_MODULE) @@ -420,6 +461,29 @@ #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE) to->ipvs_property = from->ipvs_property; #endif + +#if defined(CONFIG_FUSIV_KERNEL_AP_2_AP) || defined(CONFIG_FUSIV_KERNEL_AP_2_AP_MODULE) + memcpy(&(to->apFlowData),&(from->apFlowData),sizeof(from->apFlowData)); +#else +/* Copy the QOS related information from packet to the corresponding + fragments also */ +#if defined(CONFIG_FUSIV_KERNEL_HOST_IPQOS) || defined(CONFIG_FUSIV_KERNEL_HOST_IPQOS_MODULE) +#if CONFIG_FUSIV_KERNEL_IPQOS_APQOS + memcpy(&(to->apFlowData.qosInfo),&(from->apFlowData.qosInfo),sizeof(from->apFlowData.qosInfo)); +#else + memcpy(&(to->qosInfo),&(from->qosInfo),sizeof(from->qosInfo)); +#endif +#endif +#endif + +#ifdef CONFIG_TI_DOCSIS_INPUT_DEV + to->ti_docsis_input_dev = from->ti_docsis_input_dev; +#endif /* CONFIG_TI_DOCSIS_INPUT_DEV */ + +#ifdef CONFIG_TI_L2_SELECTIVE_FORWARDER + to->ti_selective_fwd_dev_info = from->ti_selective_fwd_dev_info; +#endif /* CONFIG_TI_L2_SELECTIVE_FORWARDER */ + skb_copy_secmark(to, from); } @@ -941,6 +1005,11 @@ skb->csum = 0; skb_reserve(skb, hh_len); +#ifdef CONFIG_TI_META_DATA + /* Fill in the meta information from the cookie. */ + skb->ti_meta_info = ipc->ti_meta_info; +#endif /* CONFIG_TI_META_DATA */ + /* * Find where to start putting bytes. */ @@ -1416,6 +1485,248 @@ #endif } +#if defined(CONFIG_FUSIV_KERNEL_AP_2_AP) || defined(CONFIG_FUSIV_KERNEL_AP_2_AP_MODULE) + +void fragmentPacket(struct sk_buff *skb, + struct fragmentInfo *fragInfo) +{ + struct sk_buff *skb2; + struct iphdr *iph = NULL; + struct pppoe_hdr *pppoeHdr = NULL; + unsigned int mtu, hlen = 0, left, len; + unsigned int ll_rs = RESERVED_SPACE_FOR_FRAGMENT; + unsigned int align = 4; /* For aligning IP header to 32-bit boundary */ + int raw = 0; + int offset; + int ptr; + int err = 0; + int macHdrLen = 0; + __be16 not_last_frag; + + if (fragInfo->moduleType == MODULE_TYPE_ADSL) + { + iph = (struct iphdr *)(skb->network_header); + hlen = (((unsigned char *) iph - ((unsigned char *) skb->data)) + + (iph->ihl * 4)); + macHdrLen = hlen - (iph->ihl * 4); + } + else if (fragInfo->moduleType == MODULE_TYPE_WLAN) + { + iph = (struct iphdr *)(skb->data + fragInfo->l2HeaderLen); + hlen = fragInfo->l2HeaderLen + (iph->ihl * 4); + macHdrLen = fragInfo->l2HeaderLen; + } + + mtu = fragInfo->mtuSize - hlen; + + left = skb->len - hlen; /* Space per frame */ + ptr = raw + hlen; /* Where to start from */ + + /* + * Fragment the datagram. + */ + + offset = (ntohs(iph->frag_off) & IP_OFFSET) << 3; + not_last_frag = iph->frag_off & htons(IP_MF); + + /* + * Keep copying data until we run out. + */ + + while (left > 0) + { + len = left; + + /* IF: it doesn't fit, use 'mtu' - the data space left */ + + if (len > mtu) + len = mtu; + + /* IF: we are not sending upto and including the packet end + then align the next start on an eight byte boundary */ + + if (len < left) + { + len &= ~7; + } + + /* + * Allocate buffer. + */ + + if ((skb2 = dev_alloc_skb(len + hlen + ll_rs + align)) == NULL) + { + printk("fragmentPacket: no memory for new fragment!\n"); + goto fail; + } + + /* + * Align IP header on 32-bit boundary as per the source buffer + * alignment. + */ + + skb_reserve(skb2, ((unsigned long) skb->data & 0x3)); + + /* + * Allow skbuff to have some head room, for growing at the front, + * required basically for WLAN protocol to add header + */ + + skb_reserve(skb2, ll_rs); + + /* + * Set up data on packet + */ + + ip_copy_metadata(skb2, skb); + skb_put(skb2, len + hlen); + + if (macHdrLen) + skb2->mac_header = skb2->data; + + skb2->network_header = skb2->data + macHdrLen; + skb2->transport_header = skb2->data + hlen; + + /* + * Charge the memory for the fragment to any owner + * it might possess + */ + + if (skb->sk) + skb_set_owner_w(skb2, skb->sk); + + /* + * Copy the packet header into the new buffer. + */ + + if (macHdrLen) + memcpy(skb2->mac_header, skb->data, macHdrLen); + + memcpy(skb2->network_header, skb->data + macHdrLen, hlen - macHdrLen); + + /* + * Copy a block of the IP datagram. + */ + + memcpy(skb2->transport_header, skb->data + ptr, len); + + memcpy(skb2->cb, skb->cb, sizeof(skb->cb)); + + left -= len; + + /* If PPPoE packet, update the total length in PPPoE Header */ + + if ((fragInfo->pktType & (1 << PKT_TYPE_PPPOE)) && + (fragInfo->pktType & (1 << PKT_TYPE_VLAN))) + { + pppoeHdr = (struct pppoe_hdr *) ((unsigned char *) skb2->data + + sizeof(struct ethhdr) + + sizeof(struct vlan_hdr)); + } + else if (fragInfo->pktType & (1 << PKT_TYPE_PPPOE)) + { + pppoeHdr = (struct pppoe_hdr *) ((unsigned char *) skb2->data + + sizeof(struct ethhdr)); + } + + if (pppoeHdr) + pppoeHdr->length = len + hlen - sizeof(struct ethhdr) + - sizeof(struct pppoe_hdr); + + /* + * Fill in the new header fields. + */ + + iph = (struct iphdr *)(skb2->network_header); + iph->frag_off = htons((offset >> 3)); + + /* ANK: dirty, but effective trick. Upgrade options only if + * the segment to be fragmented was THE FIRST (otherwise, + * options are already fixed) and make it ONCE + * on the initial skb, so that all the following fragments + * will inherit fixed options. + */ + +#if 0 // Commented out assuming that there will be no ip options in the pkt + if (offset == 0) + ip_options_fragment(skb); +#endif + + /* + * Added AC : If we are fragmenting a fragment that's not the + * last fragment then keep MF on each bit + */ + + if (left > 0 || not_last_frag) + iph->frag_off |= htons(IP_MF); + + ptr += len; + offset += len; + + /* + * Put this fragment into the sending queue. + */ + + iph->tot_len = htons(len + (iph->ihl * 4)); + + ip_send_check(iph); + + err = (fragInfo->fragment_xmit_ptr)(skb2, skb2->dev); + + if (err) + goto fail; + + IP_INC_STATS(sock_net(skb->sk), IPSTATS_MIB_FRAGCREATES); + } + + kfree_skb(skb); + IP_INC_STATS(sock_net(skb->sk), IPSTATS_MIB_FRAGOKS); + + return; + +fail: + kfree_skb(skb); + IP_INC_STATS(sock_net(skb->sk), IPSTATS_MIB_FRAGFAILS); + + return; +} + +void checkIfFragmentNeeded(struct sk_buff *skb, + struct fragmentInfo *fragInfo) +{ + unsigned short ipLen; + + ipLen = fragInfo->totalLength - fragInfo->l2HeaderLen; + + if ((fragInfo->mtuSize) && (ipLen > fragInfo->mtuSize)) + { + struct iphdr *ipHdr; + + ipHdr = (struct iphdr *)(skb->data + fragInfo->l2HeaderLen); + + if (ipHdr->frag_off & htons(IP_DF)) + kfree_skb(skb); + else + return fragmentPacket(skb, fragInfo); + } + else + { + (fragInfo->fragment_xmit_ptr)(skb, skb->dev); + + return; + } +} + +EXPORT_SYMBOL(fragmentPacket); +EXPORT_SYMBOL(checkIfFragmentNeeded); + +#endif EXPORT_SYMBOL(ip_generic_getfrag); EXPORT_SYMBOL(ip_queue_xmit); EXPORT_SYMBOL(ip_send_check); + +#if defined(CONFIG_IFX_PPA_API_MODULE) +EXPORT_SYMBOL(ip_mc_output); +EXPORT_SYMBOL(ip_forward); +EXPORT_SYMBOL(ip_local_deliver); +#endif