From: Stephen Hemminger <shemminger@vyatta.com>
To: David Miller <davem@davemloft.net>, Jay Vosburgh <fubar@us.ibm.com>
Cc: netdev@vger.kernel.org, bonding-devel@lists.sourceforge.net
Subject: [RFC 2/4] bond: add IPV6 layer3 hash policy support
Date: Thu, 04 Feb 2010 09:11:20 -0800 [thread overview]
Message-ID: <20100204171241.319788071@vyatta.com> (raw)
In-Reply-To: 20100204171118.917737392@vyatta.com
[-- Attachment #1: bond-ipv6.patch --]
[-- Type: text/plain, Size: 2176 bytes --]
Add IPV6 support to Layer 3 and Layer 3+4 hash policies.
Code take fron SFQ.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/bonding/bond_main.c 2010-02-04 08:58:54.617692952 -0800
+++ b/drivers/net/bonding/bond_main.c 2010-02-04 09:08:00.447069200 -0800
@@ -3601,13 +3601,24 @@ static u16 bond_xmit_hash_policy_l23(con
{
const struct ethhdr *data = eth_hdr(skb);
- if (skb->protocol == htons(ETH_P_IP)) {
+ switch (skb->protocol) {
+ case htons(ETH_P_IP):
+ {
const struct iphdr *iph = ip_hdr(skb);
return ntohl(iph->saddr ^ iph->daddr) ^
(data->h_dest[5] ^ data->h_source[5]);
}
+ case htons(ETH_P_IPV6):
+ {
+ const struct ipv6hdr *iph = ipv6_hdr(skb);
+ return ntohl(iph->saddr.s6_addr32[3] ^
+ iph->daddr.s6_addr32[3]) ^
+ (data->h_dest[5] ^ data->h_source[5]);
- return bond_xmit_hash_policy_l2(skb);
+ }
+ default:
+ return bond_xmit_hash_policy_l2(skb);
+ }
}
/*
@@ -3617,9 +3628,9 @@ static u16 bond_xmit_hash_policy_l23(con
*/
static u16 bond_xmit_hash_policy_l34(const struct sk_buff *skb)
{
- const struct ethhdr *data = eth_hdr(skb);
-
- if (skb->protocol == htons(ETH_P_IP)) {
+ switch (skb->protocol) {
+ case htons(ETH_P_IP):
+ {
const struct iphdr *iph = ip_hdr(skb);
const __be16 *layer4hdr
= ((const void *)iph + iph->ihl);
@@ -3627,14 +3638,28 @@ static u16 bond_xmit_hash_policy_l34(con
if (!(iph->frag_off & htons(IP_MF|IP_OFFSET)) &&
(iph->protocol == IPPROTO_TCP ||
- iph->protocol == IPPROTO_UDP)) {
+ iph->protocol == IPPROTO_UDP))
layer4_xor = ntohs((*layer4hdr ^ *(layer4hdr + 1)));
- }
+
return layer4_xor ^ ntohl(iph->saddr ^ iph->daddr);
+ }
+ case htons(ETH_P_IPV6):
+ {
+ const struct ipv6hdr *iph = ipv6_hdr(skb);
+ const __be16 *layer4hdr = (const __be16 *) (iph + 1);
+ u32 layer4_xor = 0;
+ if (iph->nexthdr == IPPROTO_TCP ||
+ iph->nexthdr == IPPROTO_UDP)
+ layer4_xor = ntohs((*layer4hdr ^ *(layer4hdr + 1)));
+
+ return layer4_xor ^
+ ntohl(iph->saddr.s6_addr32[3] ^ iph->daddr.s6_addr32[3]);
+ }
+ default:
+ return bond_xmit_hash_policy_l2(skb);
}
- return bond_xmit_hash_policy_l2(skb);
}
--
next prev parent reply other threads:[~2010-02-04 17:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-04 17:11 [RFC 0/4] bond hashing revised Stephen Hemminger
2010-02-04 17:11 ` [RFC 1/4] bond: cleanup transmit hash policy interface Stephen Hemminger
2010-02-04 17:11 ` Stephen Hemminger [this message]
2010-02-04 17:11 ` [RFC 3/4] bond: support more Layer 4 protocols Stephen Hemminger
2010-02-05 10:38 ` Patrick McHardy
2010-02-05 16:42 ` Stephen Hemminger
2010-02-08 13:11 ` Patrick McHardy
2010-02-04 17:11 ` [RFC 4/4] bond: add new multiqueue hash policy Stephen Hemminger
2010-02-05 9:40 ` [RFC 0/4] bond hashing revised Jasper Spaans
2010-02-05 21:04 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100204171241.319788071@vyatta.com \
--to=shemminger@vyatta.com \
--cc=bonding-devel@lists.sourceforge.net \
--cc=davem@davemloft.net \
--cc=fubar@us.ibm.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.