Skip to content

Commit

Permalink
Merge pull request iqiyi#402 from yeze/devel
Browse files Browse the repository at this point in the history
fix ipvsadm conhash support
  • Loading branch information
mscbg authored Mar 11, 2019
2 parents 35e4d08 + 2f145f7 commit 7317278
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 0 additions & 2 deletions tools/ipvsadm/ipvsadm.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,14 +782,12 @@ parse_options(int argc, char **argv, struct ipvs_command_entry *ce,
if (strcmp(ce->svc.sched_name, "conhash"))
fail(2 , "hash target can only be set when schedule is conhash\n");
if (!memcmp(optarg, "sip", strlen("sip"))) {
set_option(options, OPT_SIPHASH);
ce->svc.flags = ce->svc.flags | IP_VS_SVC_F_SIP_HASH;
ce->svc.flags = ce->svc.flags & (~IP_VS_SVC_F_QID_HASH);
}
else if (!memcmp(optarg, "qid", strlen("qid"))) {
if (ce->svc.protocol != IPPROTO_UDP)
fail(2 , "qid hash can only be set in udp service\n");
set_option(options, OPT_QIDHASH);
ce->svc.flags = ce->svc.flags | IP_VS_SVC_F_QID_HASH;
ce->svc.flags = ce->svc.flags & (~IP_VS_SVC_F_SIP_HASH);
}
Expand Down
16 changes: 8 additions & 8 deletions tools/keepalived/keepalived/libipvs-2.6/libipvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ int ipvs_update_service_by_options(ipvs_service_t *svc, unsigned int options)
user.flags |= IP_VS_SVC_F_ONEPACKET;
}

if( options & OPT_SIPHASH ) {
user.flags |= IP_VS_SVC_F_SIP_HASH;
user.flags &= ~IP_VS_SVC_F_QID_HASH;
}

if( options & OPT_QIDHASH ) {
user.flags |= IP_VS_SVC_F_QID_HASH;
user.flags &= ~IP_VS_SVC_F_SIP_HASH;
if( options & OPT_HASHTAG ) {
if ( svc->flags & IP_VS_SVC_F_SIP_HASH ) {
user.flags |= IP_VS_SVC_F_SIP_HASH;
} else if ( svc->flags & IP_VS_SVC_F_QID_HASH ) {
user.flags |= IP_VS_SVC_F_QID_HASH;
} else {
user.flags |= IP_VS_SVC_F_SIP_HASH;
}
}

return ipvs_update_service(&user);
Expand Down
6 changes: 2 additions & 4 deletions tools/keepalived/keepalived/libipvs-2.6/libipvs.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@
#define OPT_SYNPROXY 0x2000000
#define OPT_IFNAME 0x4000000
#define OPT_SOCKPAIR 0x8000000
#define OPT_SIPHASH 0x10000000
#define OPT_QIDHASH 0x20000000
#define OPT_HASHTAG 0x40000000
#define NUMBER_OF_OPT 31
#define OPT_HASHTAG 0x10000000
#define NUMBER_OF_OPT 29

#define MINIMUM_IPVS_VERSION_MAJOR 1
#define MINIMUM_IPVS_VERSION_MINOR 1
Expand Down

0 comments on commit 7317278

Please sign in to comment.