1 diff -Nurp linux-2.6.22.19-vs2.3.0.34/drivers/net/bonding/bond_main.c linux-2.6.22.19-vs2.3.0.34.bonding/drivers/net/bonding/bond_main.c
2 --- linux-2.6.22.19-vs2.3.0.34/drivers/net/bonding/bond_main.c 2007-09-05 07:07:59.000000000 +0200
3 +++ linux-2.6.22.19-vs2.3.0.34.bonding/drivers/net/bonding/bond_main.c 2009-06-15 21:52:30.000000000 +0200
4 @@ -123,7 +123,7 @@ MODULE_PARM_DESC(lacp_rate, "LACPDU tx r
6 module_param(xmit_hash_policy, charp, 0);
7 MODULE_PARM_DESC(xmit_hash_policy, "XOR hashing method: 0 for layer 2 (default)"
8 - ", 1 for layer 3+4");
9 + ", 1 for layer 3+4, 2 for layer2+3, 3 for layer3");
10 module_param(arp_interval, int, 0);
11 MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds");
12 module_param_array(arp_ip_target, charp, NULL, 0);
13 @@ -170,6 +170,9 @@ struct bond_parm_tbl bond_mode_tbl[] = {
14 struct bond_parm_tbl xmit_hashtype_tbl[] = {
15 { "layer2", BOND_XMIT_POLICY_LAYER2},
16 { "layer3+4", BOND_XMIT_POLICY_LAYER34},
17 +{ "layer2+3", BOND_XMIT_POLICY_LAYER23},
18 +{ "layer3", BOND_XMIT_POLICY_LAYER3},
19 +{ "rr", BOND_XMIT_POLICY_RR},
23 @@ -3447,6 +3450,40 @@ void bond_unregister_arp(struct bonding
26 /*---------------------------- Hashing Policies -----------------------------*/
29 + * Hash for the output device based upon layer 3 data. If the packet
30 + * is not IP mimic bond_xmit_hash_policy_l2()
32 +static int bond_xmit_hash_policy_l3(struct sk_buff *skb,
33 + struct net_device *bond_dev, int count)
35 + struct ethhdr *data = (struct ethhdr *)skb->data;
36 + struct iphdr *iph = ip_hdr(skb);
38 + if (skb->protocol == __constant_htons(ETH_P_IP))
39 + return (ntohl(iph->saddr ^ iph->daddr) & 0xffff) % count;
41 + return (data->h_dest[5] ^ bond_dev->dev_addr[5]) % count;
45 + * Hash for the output device based upon layer 2 and layer 3 data. If
46 + * the packet is not IP mimic bond_xmit_hash_policy_l2()
48 +static int bond_xmit_hash_policy_l23(struct sk_buff *skb,
49 + struct net_device *bond_dev, int count)
51 + struct ethhdr *data = (struct ethhdr *)skb->data;
52 + struct iphdr *iph = ip_hdr(skb);
54 + if (skb->protocol == __constant_htons(ETH_P_IP)) {
55 + return ((ntohl(iph->saddr ^ iph->daddr) & 0xffff) ^
56 + (data->h_dest[5] ^ bond_dev->dev_addr[5])) % count;
59 + return (data->h_dest[5] ^ bond_dev->dev_addr[5]) % count;
63 * Hash for the output device based upon layer 3 and layer 4 data. If
64 @@ -3486,6 +3523,16 @@ static int bond_xmit_hash_policy_l2(stru
65 return (data->h_dest[5] ^ bond_dev->dev_addr[5]) % count;
69 + * Round-robin "hashing" algorithm
71 +static int bond_xmit_hash_policy_rr(struct sk_buff *skb,
72 + struct net_device *bond_dev, int count)
74 + static atomic_t packets;
75 + return atomic_inc_return(&packets) % count;
78 /*-------------------------- Device entry points ----------------------------*/
80 static int bond_open(struct net_device *bond_dev)
81 @@ -4183,6 +4230,12 @@ void bond_set_mode_ops(struct bonding *b
82 bond_dev->hard_start_xmit = bond_xmit_xor;
83 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34)
84 bond->xmit_hash_policy = bond_xmit_hash_policy_l34;
85 + else if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER23)
86 + bond->xmit_hash_policy = bond_xmit_hash_policy_l23;
87 + else if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER3)
88 + bond->xmit_hash_policy = bond_xmit_hash_policy_l3;
89 + else if (bond->params.xmit_policy == BOND_XMIT_POLICY_RR)
90 + bond->xmit_hash_policy = bond_xmit_hash_policy_rr;
92 bond->xmit_hash_policy = bond_xmit_hash_policy_l2;
94 @@ -4194,6 +4247,12 @@ void bond_set_mode_ops(struct bonding *b
95 bond_dev->hard_start_xmit = bond_3ad_xmit_xor;
96 if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34)
97 bond->xmit_hash_policy = bond_xmit_hash_policy_l34;
98 + else if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER23)
99 + bond->xmit_hash_policy = bond_xmit_hash_policy_l23;
100 + else if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER3)
101 + bond->xmit_hash_policy = bond_xmit_hash_policy_l3;
102 + else if (bond->params.xmit_policy == BOND_XMIT_POLICY_RR)
103 + bond->xmit_hash_policy = bond_xmit_hash_policy_rr;
105 bond->xmit_hash_policy = bond_xmit_hash_policy_l2;
107 diff -Nurp linux-2.6.22.19-vs2.3.0.34/include/linux/if_bonding.h linux-2.6.22.19-vs2.3.0.34.bonding/include/linux/if_bonding.h
108 --- linux-2.6.22.19-vs2.3.0.34/include/linux/if_bonding.h 2006-06-18 03:49:35.000000000 +0200
109 +++ linux-2.6.22.19-vs2.3.0.34.bonding/include/linux/if_bonding.h 2009-06-15 22:02:09.000000000 +0200
112 #define BOND_XMIT_POLICY_LAYER2 0 /* layer 2 (MAC only), default */
113 #define BOND_XMIT_POLICY_LAYER34 1 /* layer 3+4 (IP ^ MAC) */
114 +#define BOND_XMIT_POLICY_LAYER23 2 /* layer 2+3 (IP ^ MAC) */
115 +#define BOND_XMIT_POLICY_LAYER3 3 /* layer3 (IP only) */
116 +#define BOND_XMIT_POLICY_RR 255 /* round-robin */
118 typedef struct ifbond {