-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support ah and esp protocals #775
Open
kinglory
wants to merge
2
commits into
iqiyi:devel
Choose a base branch
from
kinglory:devel
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef __DP_VS_PROTO_AH_ESP_H__ | ||
#define __DP_VS_PROTO_AH_ESP_H__ | ||
|
||
#define PORT_ISAKMP 500 | ||
|
||
enum { | ||
DPVS_AH_ESP_S_NORMAL = 0, | ||
DPVS_AH_ESP_S_LAST | ||
}; | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* DPVS is a software load balancer (Virtual Server) based on DPDK. | ||
* | ||
* Copyright (C) 2021 iQIYI (www.iqiyi.com). | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
*/ | ||
|
||
#include <assert.h> | ||
#include <netinet/ip.h> | ||
#include <netinet/ip6.h> | ||
#include "conf/common.h" | ||
#include "dpdk.h" | ||
#include "ipv4.h" | ||
#include "ipv6.h" | ||
#include "route6.h" | ||
#include "ipvs/ipvs.h" | ||
#include "ipvs/proto.h" | ||
#include "ipvs/proto_ah_esp.h" | ||
#include "ipvs/conn.h" | ||
#include "ipvs/service.h" | ||
#include "ipvs/blklst.h" | ||
#include "ipvs/redirect.h" | ||
|
||
static int esp_timeouts[DPVS_AH_ESP_S_LAST + 1] = { | ||
[DPVS_AH_ESP_S_NORMAL] = 300, | ||
[DPVS_AH_ESP_S_LAST] = 2, | ||
}; | ||
|
||
static int esp_conn_sched(struct dp_vs_proto *proto, | ||
const struct dp_vs_iphdr *iph, | ||
struct rte_mbuf *mbuf, | ||
struct dp_vs_conn **conn, | ||
int *verdict) | ||
{ | ||
/* | ||
struct dp_vs_service *svc; | ||
bool outwall = false; | ||
assert(proto && iph && mbuf && conn && verdict); | ||
|
||
svc = dp_vs_service_lookup(iph->af, iph->proto, &iph->daddr, 0, 0, mbuf, NULL, &outwall, rte_lcore_id()); | ||
if (!svc) { | ||
*verdict = INET_ACCEPT; | ||
return EDPVS_NOSERV; | ||
} | ||
|
||
*conn = dp_vs_schedule(svc, iph, mbuf, false, outwall); | ||
if (!*conn) { | ||
*verdict = INET_DROP; | ||
return EDPVS_RESOURCE; | ||
} | ||
return EDPVS_OK; | ||
*/ | ||
|
||
// 在发送esp报文之前应该已经通过UDP协商报文建立会话,该流程理应永远不会走到。 | ||
*verdict = INET_ACCEPT; | ||
return EDPVS_DROP; | ||
} | ||
|
||
static struct dp_vs_conn * | ||
esp_conn_lookup(struct dp_vs_proto *proto, | ||
const struct dp_vs_iphdr *iph, | ||
struct rte_mbuf *mbuf, int *direct, | ||
bool reverse, bool *drop, lcoreid_t *peer_cid) | ||
{ | ||
struct dp_vs_conn *conn; | ||
assert(proto && iph && mbuf); | ||
|
||
conn = dp_vs_conn_get(iph->af, IPPROTO_UDP, | ||
&iph->saddr, &iph->daddr, | ||
htons(PORT_ISAKMP), htons(PORT_ISAKMP), | ||
direct, reverse); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it need to support connection redirection? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's logic for the first negotiation packages and the process is similar to the kernel ipvs code. |
||
return conn; | ||
} | ||
|
||
static int esp_state_trans(struct dp_vs_proto *proto, struct dp_vs_conn *conn, | ||
struct rte_mbuf *mbuf, int dir) | ||
{ | ||
conn->state = DPVS_AH_ESP_S_NORMAL; | ||
conn->timeout.tv_sec = esp_timeouts[conn->state]; | ||
return EDPVS_OK; | ||
} | ||
|
||
|
||
struct dp_vs_proto dp_vs_proto_ah = { | ||
.name = "AH", | ||
.proto = IPPROTO_AH, | ||
.conn_sched = esp_conn_sched, | ||
.conn_lookup = esp_conn_lookup, | ||
.state_trans = esp_state_trans, | ||
}; | ||
|
||
struct dp_vs_proto dp_vs_proto_esp = { | ||
.name = "ESP", | ||
.proto = IPPROTO_ESP, | ||
.conn_sched = esp_conn_sched, | ||
.conn_lookup = esp_conn_lookup, | ||
.state_trans = esp_state_trans, | ||
}; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please unregister protocols in the reverse order when error occurs. Note the label sequence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I have fixed it. thank you.