Skip to content

Commit

Permalink
bugfix: fix issue iqiyi#711
Browse files Browse the repository at this point in the history
  • Loading branch information
ywc689 committed Feb 5, 2021
1 parent 8ce85e2 commit 0cbef0f
Show file tree
Hide file tree
Showing 8 changed files with 338 additions and 539 deletions.
29 changes: 29 additions & 0 deletions include/conf/conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,35 @@
#include "inet.h"
#include "conf/sockopts.h"

/*
* IPVS Conn flags derived from "linux/ip_vs.h".
*
* Note: We just keep the macros used by dpvs/keepalived, and the value for some macros
* are changed. Besides, some new macros are added for dpvs.
*/
/* Conn flags used by DPVS and Keepalived */
#define IP_VS_CONN_F_MASQ 0x0000 /* masquerading/NAT */
#define IP_VS_CONN_F_LOCALNODE 0x0001 /* local node */
#define IP_VS_CONN_F_TUNNEL 0x0002 /* tunneling */
#define IP_VS_CONN_F_DROUTE 0x0003 /* direct routing */
#define IP_VS_CONN_F_BYPASS 0x0004 /* cache bypass */
#define IP_VS_CONN_F_FULLNAT 0x0005 /* full nat mode */
#define IP_VS_CONN_F_SNAT 0x0006 /* snat mode */
#define IP_VS_CONN_F_FWD_MASK 0x0007 /* mask for the fwd methods */

#define IP_VS_CONN_F_SYNPROXY 0x0010 /* synproxy switch flag*/
#define IP_VS_CONN_F_EXPIRE_QUIESCENT 0x0020 /* expire quiescent conns */

/* Conn flags used by DPVS only */
#define IP_VS_CONN_F_HASHED 0x0100 /* hashed entry */
#define IP_VS_CONN_F_INACTIVE 0x0200 /* not established */
#define IP_VS_CONN_F_TEMPLATE 0x0400 /* template, not connection */
#define IP_VS_CONN_F_ONE_PACKET 0x0800 /* forward only one packet */

#define IP_VS_CONN_F_IN_TIMER 0x1000 /* timer attached */
#define IP_VS_CONN_F_REDIRECT_HASHED 0x2000 /* hashed in redirect table */
#define IP_VS_CONN_F_NOFASTXMIT 0x4000 /* do not fastxmit */

/* How many connections returned at most for one sockopt ctrl msg.
* Decrease it for saving memory, increase it for better performace.
*/
Expand Down
21 changes: 12 additions & 9 deletions include/conf/dest.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@
#define __DPVS_DEST_CONF_H__

#include "conf/service.h"
#include "conf/conn.h"

/* must consistent with IP_VS_CONN_F_XXX (libipvs-2.6/ip_vs.h) */
/*
* DPVS_FWD_XXX should always be the same with IP_VS_CONN_F_XXX.
*/
enum dpvs_fwd_mode {
DPVS_FWD_MASQ = 0,
DPVS_FWD_LOCALNODE = 1,
DPVS_FWD_MODE_TUNNEL = 2,
DPVS_FWD_MODE_DR = 3,
DPVS_FWD_MODE_BYPASS = 4,
DPVS_FWD_MODE_FNAT = 5,
DPVS_FWD_MODE_NAT = DPVS_FWD_MASQ,
DPVS_FWD_MODE_SNAT = 6,
DPVS_FWD_MASQ = IP_VS_CONN_F_MASQ,
DPVS_FWD_LOCALNODE = IP_VS_CONN_F_LOCALNODE,
DPVS_FWD_MODE_TUNNEL = IP_VS_CONN_F_TUNNEL,
DPVS_FWD_MODE_DR = IP_VS_CONN_F_DROUTE,
DPVS_FWD_MODE_BYPASS = IP_VS_CONN_F_BYPASS,
DPVS_FWD_MODE_FNAT = IP_VS_CONN_F_FULLNAT,
DPVS_FWD_MODE_SNAT = IP_VS_CONN_F_SNAT,
DPVS_FWD_MODE_NAT = DPVS_FWD_MASQ,
};

enum {
Expand Down
15 changes: 15 additions & 0 deletions include/conf/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@

#define DP_VS_SCHEDNAME_MAXLEN 16

/*
* Virtual Service Flags derived from "linux/ip_vs.h"
*/
#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_SCHED1 0x0008 /* scheduler flag 1 */
#define IP_VS_SVC_F_SCHED2 0x0010 /* scheduler flag 2 */
#define IP_VS_SVC_F_SCHED3 0x0020 /* scheduler flag 3 */
#define IP_VS_SVC_F_SIP_HASH 0x0100 /* sip hash target */
#define IP_VS_SVC_F_QID_HASH 0x0200 /* quic cid hash target */
#define IP_VS_SVC_F_MATCH 0x0400 /* snat match */
#define IP_VS_SVC_F_SCHED_SH_FALLBACK IP_VS_SVC_F_SCHED1 /* SH fallback */
#define IP_VS_SVC_F_SCHED_SH_PORT IP_VS_SVC_F_SCHED2 /* SH use port */

struct dp_vs_service_conf {
/* virtual service addresses */
uint16_t af;
Expand Down
25 changes: 14 additions & 11 deletions include/ipvs/conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@ enum {
DPVS_CONN_DIR_MAX,
};

enum {
DPVS_CONN_F_HASHED = 0x0040,
DPVS_CONN_F_REDIRECT_HASHED = 0x0080,
DPVS_CONN_F_INACTIVE = 0x0100,
DPVS_CONN_F_IN_TIMER = 0x0200,
DPVS_CONN_F_EXPIRE_QUIESCENT = 0x4000,
DPVS_CONN_F_SYNPROXY = 0x8000,
DPVS_CONN_F_TEMPLATE = 0x1000,
DPVS_CONN_F_NOFASTXMIT = 0x2000,
DPVS_CONN_F_ONE_PACKET = 0x0400,
};
/*
* DPVS_CONN_F_XXX should always be the same with IP_VS_CONN_F_XXX.
*/
/* Conn flags used by both DPVS and Keepalived*/
#define DPVS_CONN_F_SYNPROXY IP_VS_CONN_F_SYNPROXY
#define DPVS_CONN_F_EXPIRE_QUIESCENT IP_VS_CONN_F_EXPIRE_QUIESCENT
/* Conn flags used by DPVS only */
#define DPVS_CONN_F_HASHED IP_VS_CONN_F_HASHED
#define DPVS_CONN_F_INACTIVE IP_VS_CONN_F_INACTIVE
#define DPVS_CONN_F_TEMPLATE IP_VS_CONN_F_TEMPLATE
#define DPVS_CONN_F_ONE_PACKET IP_VS_CONN_F_ONE_PACKET
#define DPVS_CONN_F_IN_TIMER IP_VS_CONN_F_IN_TIMER
#define DPVS_CONN_F_REDIRECT_HASHED IP_VS_CONN_F_REDIRECT_HASHED
#define DPVS_CONN_F_NOFASTXMIT IP_VS_CONN_F_NOFASTXMIT

struct dp_vs_conn_param {
int af;
Expand Down
24 changes: 12 additions & 12 deletions include/ipvs/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
#include "conf/match.h"
#include "conf/service.h"

#define RTE_LOGTYPE_SERVICE RTE_LOGTYPE_USER3
#define DP_VS_SVC_F_PERSISTENT 0x0001 /* peristent port */
#define DP_VS_SVC_F_HASHED 0x0002 /* hashed entry */
#define DP_VS_SVC_F_ONEPACKET 0x0004 /* one-packet scheduling */
#define DP_VS_SVC_F_SCHED1 0x0008 /* scheduler flag 1 */
#define DP_VS_SVC_F_SCHED2 0x0010 /* scheduler flag 2 */
#define DP_VS_SVC_F_SCHED3 0x0020 /* scheduler flag 3 */

#define DP_VS_SVC_F_SIP_HASH 0x0100 /* sip hash target */
#define DP_VS_SVC_F_QID_HASH 0x0200 /* quic cid hash target */
#define DP_VS_SVC_F_MATCH 0x0400 /* snat match */
#define DP_VS_SVC_F_SYNPROXY 0x8000 /* synrpoxy flag */
#define RTE_LOGTYPE_SERVICE RTE_LOGTYPE_USER3

/* DP_VS_SVC_F_XXX should always be the same with IP_VS_SVC_F_XXX */
#define DP_VS_SVC_F_PERSISTENT IP_VS_SVC_F_PERSISTENT
#define DP_VS_SVC_F_HASHED IP_VS_SVC_F_HASHED
#define DP_VS_SVC_F_ONEPACKET IP_VS_SVC_F_ONEPACKET
#define DP_VS_SVC_F_SCHED1 IP_VS_SVC_F_SCHED1
#define DP_VS_SVC_F_SCHED2 IP_VS_SVC_F_SCHED2
#define DP_VS_SVC_F_SCHED3 IP_VS_SVC_F_SCHED3
#define DP_VS_SVC_F_SIP_HASH IP_VS_SVC_F_SIP_HASH
#define DP_VS_SVC_F_QID_HASH IP_VS_SVC_F_QID_HASH
#define DP_VS_SVC_F_MATCH IP_VS_SVC_F_MATCH

/* virtual service */
struct dp_vs_service {
Expand Down
2 changes: 1 addition & 1 deletion src/ipvs/ip_vs_synproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ int dp_vs_synproxy_syn_rcv(int af, struct rte_mbuf *mbuf,
if (th->syn && !th->ack && !th->rst && !th->fin &&
(svc = dp_vs_service_lookup(af, iph->proto, &iph->daddr, th->dest, 0,
NULL, NULL, NULL, rte_lcore_id())) &&
(svc->flags & DP_VS_SVC_F_SYNPROXY)) {
(svc->flags & DPVS_CONN_F_SYNPROXY)) {
/* if service's weight is zero (non-active realserver),
* do noting and drop the packet */
if (svc->weight == 0) {
Expand Down
Loading

0 comments on commit 0cbef0f

Please sign in to comment.