forked from kmesh-net/kmesh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhang-mingyi66
committed
Sep 25, 2023
1 parent
5dcce63
commit 29fa149
Showing
11 changed files
with
262 additions
and
103 deletions.
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
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,49 @@ | ||
/* | ||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* When the two ends use loopback addresses for communication, there is a | ||
* low probability that link conflicts occur. The namespace cookie | ||
* corresponding to each container is added to the hash key to avoid | ||
* loopback address link conflicts. Obtains the namespace cookie of the | ||
* current container based on the bpf_get_netns_cookie auxiliary function. | ||
*/ | ||
#define MDA_LOOPBACK_ADDR 1 | ||
|
||
/* supports NAT acceleration. That is, acceleration can also be performed | ||
* when iptables is used to forward traffic between service containers | ||
* and sidecar containers. The bpf_sk_original_addr auxiliary function is | ||
* used to obtain the original destination address. | ||
*/ | ||
#define MDA_NAT_ACCEL 1 | ||
|
||
/* supports acceleration function filtering based on GID and UID. | ||
* That is, the GID or UID corresponding to the process to be accelerated | ||
* is configured in the configuration file. The bpf_get_sockops_uid_gid | ||
* auxiliary function is used to obtain the GID and UID of the current | ||
* process. | ||
*/ | ||
#define MDA_GID_UID_FILTER 1 | ||
|
||
/* In the kernel network protocol stack, the port is stored in u16, | ||
* but in the bpf network module, the port is stored in u32. Therefore, | ||
* after the endian conversion, the 16-bit port needs to be obtained from | ||
* the 32-bit data structure. You need to find the position of the valid | ||
* 16 bits. Generally, after the port is extended from 16 bits to 32 bits, | ||
* the port is in the upper 16 bits after the endian conversion. | ||
* Therefore, you need to offset the port before using the u16 RX port. | ||
* In some specific kernels, the port stored in sockops is in the lower | ||
* 16 bits and does not need to be offset. | ||
*/ | ||
#define MDA_PORT_OFFSET 1 |
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,9 @@ | ||
#!/bin/bash | ||
|
||
ROOT_DIR=$(dirname $(readlink -f ${BASH_SOURCE[0]})) | ||
VERSION=$(uname -r | cut -d '.' -f 1,2) | ||
OE_VERSION=$(uname -r | grep -o 'oe[^.]*') | ||
|
||
if [ "$OE_VERSION" == "oe2303" ]; then | ||
cp $ROOT_DIR/depends/include/6.1/bpf_helper_defs_ext.h $ROOT_DIR/bpf/include/ | ||
fi |
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,33 @@ | ||
#!/bin/bash | ||
|
||
VERSION=$(uname -r | cut -d '.' -f 1,2) | ||
OE_VERSION=$(uname -r | grep -o 'oe[^.]*') | ||
|
||
function set_config() { | ||
sed -i -r -e "s/($1)([ \t]*)([0-9]+)/\1\2$2/" config/kmesh_marcos_def.h | ||
} | ||
|
||
function set_config_oe2303() { | ||
set_config MDA_LOOPBACK_ADDR 1 | ||
set_config MDA_NAT_ACCEL 0 | ||
set_config MDA_GID_UID_FILTER 0 | ||
set_config MDA_PORT_OFFSET 0 | ||
} | ||
|
||
function set_config_all_disabled() { | ||
set_config MDA_LOOPBACK_ADDR 0 | ||
set_config MDA_NAT_ACCEL 0 | ||
set_config MDA_GID_UID_FILTER 0 | ||
set_config MDA_PORT_OFFSET 1 | ||
} | ||
|
||
function set_kmesh_env_config() { | ||
|
||
# openEuler 2303 | ||
if [ "$OE_VERSION" == "oe2303" ]; then | ||
set_config_oe2303 | ||
else | ||
set_config_all_disabled | ||
fi | ||
} | ||
set_kmesh_env_config |
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
Oops, something went wrong.