Skip to content

Commit

Permalink
add ali_lvs v3 beta,kernel-ipvs and tools-keepalived,ipvsadm,quagga
Browse files Browse the repository at this point in the history
  • Loading branch information
wujiaming committed Jul 3, 2013
1 parent f2ce5eb commit fe0892f
Show file tree
Hide file tree
Showing 35 changed files with 2,660 additions and 1,179 deletions.
4 changes: 2 additions & 2 deletions kernel/drivers/net/ixgbe/ixgbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@
__func__ , ## args)))

/* TX/RX descriptor defines */
#define IXGBE_DEFAULT_TXD 512
#define IXGBE_DEFAULT_TXD 4096
#define IXGBE_DEFAULT_TX_WORK 256
#define IXGBE_MAX_TXD 4096
#define IXGBE_MIN_TXD 64

#define IXGBE_DEFAULT_RXD 512
#define IXGBE_DEFAULT_RXD 4096
#define IXGBE_DEFAULT_RX_WORK 256
#define IXGBE_MAX_RXD 4096
#define IXGBE_MIN_RXD 64
Expand Down
19 changes: 13 additions & 6 deletions kernel/drivers/net/ixgbe/ixgbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3435,11 +3435,13 @@ static void ixgbe_setup_mrqc(struct ixgbe_adapter *adapter)
0x6A3E67EA, 0x14364D17, 0x3BED200D};
u32 mrqc = 0, reta = 0;
u32 rxcsum;
int i, j;
int i, j, offset, rss_limit;
int maxq = adapter->ring_feature[RING_F_RSS].indices;
int mask;
u8 tcs = netdev_get_num_tc(adapter->netdev);

pr_info("maxq=%d,num_tx_queues=%d, tcs=%u\n",
maxq, adapter->num_tx_queues, tcs);
#ifdef HAVE_MQPRIO
if (tcs)
maxq = min(maxq, adapter->num_tx_queues / tcs);
Expand All @@ -3449,15 +3451,19 @@ static void ixgbe_setup_mrqc(struct ixgbe_adapter *adapter)
for (i = 0; i < 10; i++)
IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), seed[i]);

rss_limit = min_t(int, adapter->num_tx_queues,
IXGBE_MAX_RSS_INDICES);
offset = (rss_limit > maxq) ? (rss_limit - maxq) : 0;
/* Fill out redirection table */
for (i = 0, j = 0; i < 128; i++, j++) {
if (j == maxq)
j = 0;
for (i = 0, j = offset; i < 128; i++, j++) {
if (j == (maxq + offset))
j = offset;
/* reta = 4-byte sliding window of
* 0x00..(indices-1)(indices-1)00..etc. */
reta = (reta << 8) | (j * 0x11);
if ((i & 3) == 3)
if ((i & 3) == 3) {
IXGBE_WRITE_REG(hw, IXGBE_RETA(i >> 2), reta);
}
}

/* Disable indicating checksum in descriptor, enables RSS hash */
Expand Down Expand Up @@ -8725,7 +8731,8 @@ static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb)
}
#endif /* IXGBE_FCOE */

if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) {
if (adapter->flags & (IXGBE_FLAG_FDIR_HASH_CAPABLE |
IXGBE_FLAG_FDIR_PERFECT_CAPABLE)) {
while (unlikely(txq >= dev->real_num_tx_queues))
txq -= dev->real_num_tx_queues;
return txq;
Expand Down
8 changes: 7 additions & 1 deletion kernel/drivers/net/ixgbe/ixgbe_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,9 +1022,15 @@ void __devinit ixgbe_check_options(struct ixgbe_adapter *adapter)

/* limit the number of queues for FDIR using RSS param */
if (feature[RING_F_RSS].indices && num_RSS > bd && RSS[bd])
{
feature[RING_F_FDIR].indices =
feature[RING_F_RSS].indices;
min_t(int, num_online_cpus(),
feature[RING_F_FDIR].indices);

DPRINTK(PROBE, INFO, "FDIR.indices:%d, RSS.indices:%d\n",
feature[RING_F_FDIR].indices,
feature[RING_F_RSS].indices);
}
no_flow_director:
/* empty code line with semi-colon */ ;
}
Expand Down
3 changes: 3 additions & 0 deletions kernel/include/linux/ip_vs.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define IP_VS_SVC_F_PERSISTENT 0x0001 /* persistent port */
#define IP_VS_SVC_F_HASHED 0x0002 /* hashed entry */
#define IP_VS_SVC_F_ONEPACKET 0x0004 /* one-packet scheduling */
#define IP_VS_SVC_F_SYNPROXY 0x8000 /* synproxy flag */

/*
* Destination Server Flags
Expand Down Expand Up @@ -352,6 +353,8 @@ enum {
IPVS_SVC_ATTR_NETMASK, /* persistent netmask */

IPVS_SVC_ATTR_STATS, /* nested attribute for service stats */
IPVS_SVC_ATTR_EST_TIMEOUT, /* establish timeout */

__IPVS_SVC_ATTR_MAX,
};

Expand Down
49 changes: 41 additions & 8 deletions kernel/include/net/ip_vs.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ struct ip_vs_protocol {
struct ip_vs_protocol * pp,
struct ip_vs_conn * cp);

int (*fnat_in_handler) (struct sk_buff ** skb_p,
int (*fnat_in_handler) (struct sk_buff * skb,
struct ip_vs_protocol * pp,
struct ip_vs_conn * cp);

Expand Down Expand Up @@ -381,6 +381,8 @@ struct ip_vs_conn {
* state transition triggerd
* synchronization
*/
u16 cpuid;

/* Control members */
struct ip_vs_conn *control; /* Master control connection */
atomic_t n_control; /* Number of controlled ones */
Expand Down Expand Up @@ -424,8 +426,19 @@ struct ip_vs_conn {

/* L2 direct response xmit */
struct net_device *indev;
unsigned char src_hwaddr[MAX_ADDR_LEN];
unsigned char dst_hwaddr[MAX_ADDR_LEN];
unsigned char src_hwaddr[ETH_ALEN];
unsigned char dst_hwaddr[ETH_ALEN];
struct net_device *dev_inside;
unsigned char src_hwaddr_inside[ETH_ALEN];
unsigned char dst_hwaddr_inside[ETH_ALEN];

int est_timeout; /* Now, we decide that every VS
* should have its private
* establish state timeout for user requirement.
* Each conn inherit this value from VS and
* set this value into conn timer
* when state change to establishment
*/
};

/*
Expand All @@ -449,6 +462,7 @@ struct ip_vs_service_user_kern {
unsigned flags; /* virtual service flags */
unsigned timeout; /* persistent timeout in sec */
u32 netmask; /* persistent netmask */
unsigned est_timeout; /* vs private establish state timeout */
};

struct ip_vs_dest_user_kern {
Expand Down Expand Up @@ -477,7 +491,6 @@ struct ip_vs_service {
struct list_head s_list; /* for normal service table */
struct list_head f_list; /* for fwmark-based service table */
atomic_t refcnt; /* reference counter */
atomic_t usecnt; /* use counter */

u16 af; /* address family */
__u16 protocol; /* which protocol (TCP/UDP) */
Expand All @@ -491,20 +504,26 @@ struct ip_vs_service {
/* for realservers list */
struct list_head destinations; /* real server d-linked list */
__u32 num_dests; /* number of servers */
long weight; /* sum of servers weight */

/* for local ip address list, now only used in FULL NAT model */
struct list_head laddr_list; /* local ip address list */
rwlock_t laddr_lock; /* lock for protect curr_laddr */
__u32 num_laddrs; /* number of local ip address */
struct list_head *curr_laddr; /* laddr data list head */

struct ip_vs_stats *stats; /* Use per-cpu statistics for the service */
struct ip_vs_stats stats; /* statistics for the service */
struct ip_vs_app *inc; /* bind conns to this app inc */

/* for scheduling */
struct ip_vs_scheduler *scheduler; /* bound scheduler object */
rwlock_t sched_lock; /* lock sched_data */
void *sched_data; /* scheduler application data */

/* for VS private establish state timeout, it should be inherited by every connection data structure */
unsigned est_timeout;

struct ip_vs_service *svc0; /* the svc of cpu0 */
};

/*
Expand All @@ -523,7 +542,7 @@ struct ip_vs_dest {
atomic_t weight; /* server weight */

atomic_t refcnt; /* reference counter */
struct ip_vs_stats *stats; /* Use per-cpu statistics for destination server */
struct ip_vs_stats stats; /* statistics for destination server */

/* connection counters and thresholds */
atomic_t activeconns; /* active connections */
Expand Down Expand Up @@ -551,6 +570,7 @@ struct ip_vs_dest {
struct ip_vs_laddr {
struct list_head n_list; /* for the local address in the service */
u16 af; /* address family */
u16 cpuid; /* record the cpu laddr has been assigned */
union nf_inet_addr addr; /* ip address */
atomic64_t port; /* port counts */
atomic_t refcnt; /* reference count */
Expand Down Expand Up @@ -710,6 +730,9 @@ enum {
FAST_XMIT_NO_MAC,
FAST_XMIT_SYNPROXY_SAVE,
FAST_XMIT_DEV_LOST,
FAST_XMIT_REJECT_INSIDE,
FAST_XMIT_PASS_INSIDE,
FAST_XMIT_SYNPROXY_SAVE_INSIDE,
RST_IN_SYN_SENT,
RST_OUT_SYN_SENT,
RST_IN_ESTABLISHED,
Expand All @@ -718,6 +741,8 @@ enum {
LRO_REJECT,
XMIT_UNEXPECTED_MTU,
CONN_SCHED_UNREACH,
SYNPROXY_NO_DEST,
CONN_EXCEEDED,
IP_VS_EXT_STAT_LAST
};

Expand Down Expand Up @@ -767,7 +792,8 @@ extern void ip_vs_init_hash_table(struct list_head *table, int rows);
#define CONFIG_IP_VS_TAB_BITS 22
#endif

#define IP_VS_CONN_TAB_BITS CONFIG_IP_VS_TAB_BITS
//#define IP_VS_CONN_TAB_BITS CONFIG_IP_VS_TAB_BITS
#define IP_VS_CONN_TAB_BITS 20
#define IP_VS_CONN_TAB_SIZE (1 << IP_VS_CONN_TAB_BITS)
#define IP_VS_CONN_TAB_MASK (IP_VS_CONN_TAB_SIZE - 1)

Expand Down Expand Up @@ -954,6 +980,12 @@ extern int sysctl_ip_vs_tcp_drop_entry;
extern int sysctl_ip_vs_udp_drop_entry;
extern int sysctl_ip_vs_conn_expire_tcp_rst;
extern int sysctl_ip_vs_fast_xmit;
extern int sysctl_ip_vs_fast_xmit_inside;
extern int sysctl_ip_vs_csum_offload;
extern int sysctl_ip_vs_reserve_core;
extern int sysctl_ip_vs_conn_max_num;

DECLARE_PER_CPU(spinlock_t, ip_vs_svc_lock);

extern struct ip_vs_service *ip_vs_service_get(int af, __u32 fwmark,
__u16 protocol,
Expand All @@ -964,7 +996,8 @@ extern struct ip_vs_service *ip_vs_lookup_vip(int af, __u16 protocol,

static inline void ip_vs_service_put(struct ip_vs_service *svc)
{
atomic_dec(&svc->usecnt);
if (likely(svc != NULL))
spin_unlock(&__get_cpu_var(ip_vs_svc_lock));
}

extern struct ip_vs_dest *ip_vs_lookup_real_service(int af, __u16 protocol,
Expand Down
22 changes: 6 additions & 16 deletions kernel/include/net/ip_vs_synproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
* [19-16] snd_wscale
* [15-0] MSSIND
*/
#define IP_VS_SYNPROXY_MSS_BITS 16
#define IP_VS_SYNPROXY_MSS_MASK (((__u32)1 << IP_VS_SYNPROXY_MSS_BITS) - 1)
#define IP_VS_SYNPROXY_OTHER_BITS 12
#define IP_VS_SYNPROXY_OTHER_MASK (((__u32)1 << IP_VS_SYNPROXY_OTHER_BITS)-1)
#define IP_VS_SYNPROXY_MSS_BITS 12
#define IP_VS_SYNPROXY_MSS_MASK ((__u32)0xf << IP_VS_SYNPROXY_MSS_BITS)

#define IP_VS_SYNPROXY_SACKOK_BIT 21
#define IP_VS_SYNPROXY_SACKOK_MASK ((__u32)1 << IP_VS_SYNPROXY_SACKOK_BIT)
Expand All @@ -38,20 +40,8 @@ struct ip_vs_synproxy_opt {
u16 mss_clamp; /* Maximal mss, negotiated at connection setup */
};

/*
* For syncookie compute and check
*/
extern __u32 ip_vs_synproxy_cookie_v4_init_sequence(struct sk_buff *skb,
struct ip_vs_synproxy_opt
*opts);
extern int ip_vs_synproxy_v4_cookie_check(struct sk_buff *skb, __u32 cookie,
struct ip_vs_synproxy_opt *opt);

extern __u32 ip_vs_synproxy_cookie_v6_init_sequence(struct sk_buff *skb,
struct ip_vs_synproxy_opt
*opts);
extern int ip_vs_synproxy_v6_cookie_check(struct sk_buff *skb, __u32 cookie,
struct ip_vs_synproxy_opt *opt);
/* syncookie init */
extern int ip_vs_net_secret_init(void);

/*
* Syn-proxy step 1 logic: receive client's Syn.
Expand Down
11 changes: 6 additions & 5 deletions kernel/net/ipv4/syncookies.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ static __u16 const msstab[] = {
512 - 1,
536 - 1,
1024 - 1,
1280 - 1,
1440 - 1,
1452 - 1,
1460 - 1,
4312 - 1,
(__u16)-1
Expand Down Expand Up @@ -374,7 +376,7 @@ out: return ret;
* [21] SACKOK
* [20] TimeStampOK
* [19-16] snd_wscale
* [15-0] MSSIND
* [15-12] MSSIND
*/
__u32 ip_vs_synproxy_cookie_v4_init_sequence(struct sk_buff *skb,
struct ip_vs_synproxy_opt *opts)
Expand All @@ -390,7 +392,7 @@ __u32 ip_vs_synproxy_cookie_v4_init_sequence(struct sk_buff *skb,
;
opts->mss_clamp = msstab[mssind] + 1;

data = mssind & IP_VS_SYNPROXY_MSS_MASK;
data = ((mssind & 0x0f) << IP_VS_SYNPROXY_MSS_BITS);
data |= opts->sack_ok << IP_VS_SYNPROXY_SACKOK_BIT;
data |= opts->tstamp_ok << IP_VS_SYNPROXY_TSOK_BIT;
data |= ((opts->snd_wscale & 0x0f) << IP_VS_SYNPROXY_SND_WSCALE_BITS);
Expand Down Expand Up @@ -424,11 +426,10 @@ int ip_vs_synproxy_v4_cookie_check(struct sk_buff * skb, __u32 cookie,
if(res == (__u32)-1) /* count is invalid, jiffies' >> jiffies */
goto out;

mssind = res & IP_VS_SYNPROXY_MSS_MASK;
mssind = (res & IP_VS_SYNPROXY_MSS_MASK) >> IP_VS_SYNPROXY_MSS_BITS;

memset(opt, 0, sizeof(struct ip_vs_synproxy_opt));

if (mssind < NUM_MSS) {
if ((mssind < NUM_MSS) && ((res & IP_VS_SYNPROXY_OTHER_MASK) == 0)) {
opt->mss_clamp = msstab[mssind] + 1;
opt->sack_ok = (res & IP_VS_SYNPROXY_SACKOK_MASK) >>
IP_VS_SYNPROXY_SACKOK_BIT;
Expand Down
10 changes: 6 additions & 4 deletions kernel/net/ipv6/syncookies.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ static __u16 const msstab[] = {
512 - 1,
536 - 1,
1024 - 1,
1280 - 1,
1440 - 1,
1452 - 1,
1460 - 1,
4312 - 1,
(__u16)-1
Expand Down Expand Up @@ -289,7 +291,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
* [21] SACKOK
* [20] TimeStampOK
* [19-16] snd_wscale
* [15-0] MSSIND
* [15-12] MSSIND
*/
__u32 ip_vs_synproxy_cookie_v6_init_sequence(struct sk_buff *skb,
struct ip_vs_synproxy_opt *opts)
Expand All @@ -305,7 +307,7 @@ __u32 ip_vs_synproxy_cookie_v6_init_sequence(struct sk_buff *skb,
;
opts->mss_clamp = msstab[mssind] + 1;

data = mssind & IP_VS_SYNPROXY_MSS_MASK;
data = ((mssind & 0x0f) << IP_VS_SYNPROXY_MSS_BITS);
data |= opts->sack_ok << IP_VS_SYNPROXY_SACKOK_BIT;
data |= opts->tstamp_ok << IP_VS_SYNPROXY_TSOK_BIT;
data |= ((opts->snd_wscale & 0x0f) << IP_VS_SYNPROXY_SND_WSCALE_BITS);
Expand Down Expand Up @@ -338,11 +340,11 @@ int ip_vs_synproxy_v6_cookie_check(struct sk_buff * skb, __u32 cookie,
if(res == (__u32)-1) /* count is invalid, jiffies' >> jiffies */
goto out;

mssind = res & IP_VS_SYNPROXY_MSS_MASK;
mssind = (res & IP_VS_SYNPROXY_MSS_MASK) >> IP_VS_SYNPROXY_MSS_BITS;

memset(opt, 0, sizeof(struct ip_vs_synproxy_opt));

if (mssind < NUM_MSS) {
if ((mssind < NUM_MSS) && ((res & IP_VS_SYNPROXY_OTHER_MASK) == 0)) {
opt->mss_clamp = msstab[mssind] + 1;
opt->sack_ok = (res & IP_VS_SYNPROXY_SACKOK_MASK) >>
IP_VS_SYNPROXY_SACKOK_BIT;
Expand Down
Loading

0 comments on commit fe0892f

Please sign in to comment.