Search K
Appearance
Appearance
tuntap 的组件名称为 tuntap, 相关内核选项为
# Device Drivers
# -> Network device support
# -> Network core driver support
# -> Universal TUN/TAP device driver support
CONFIG_TUN=y检查工具为
#!/opt/sum/bin/bash
source ./cmd_utils.sh
source ./kernel_config_utils.sh
source ./net_utils.sh
tuntap_check() {
if ! kernel_config_check CONFIG_TUN tun; then
return 1
fi
local ifname="dodo"
netif_delete $ifname
if ! ${IP_CMD} tuntap add mode tap name $ifname; then
echo "create tun failed"
return 1
fi
if ! netif_check $ifname; then
echo "netif not exist: ifname $ifname"
return 1
fi
netif_delete $ifname
return 0
}veth 的组件名称为 veth, 相关内核选项为
# Device Drivers
# -> Network device support
# -> Network core driver support
# -> Virtual ethernet pair device
CONFIG_VETH=y检查工具为
#!/opt/sum/bin/bash
source ./cmd_utils.sh
source ./kernel_config_utils.sh
source ./net_utils.sh
veth_check() {
local is_error=false
if ! kernel_config_check CONFIG_VETH veth; then
return 1
fi
ifname="dodo"
peer_ifname="lala"
netif_delete $ifname
netif_delete $peer_ifname
while :
do
if ! ${IP_CMD} link add name $ifname type veth peer name $peer_ifname; then
echo "create veth failed"
is_error=true
break
fi
if ! netif_check $ifname; then
echo "netif not exist: ifname $ifname"
is_error=true
break
fi
if ! netif_check $peer_ifname; then
echo "netif not exist: peer_ifname $peer_ifname"
is_error=true
break
fi
if ! ${ETHTOOL_CMD} --show-channels $ifname > /dev/null 2>&1; then
echo "veth not support multi channels: ifname $ifname"
is_error=true
break
fi
if ! ${ETHTOOL_CMD} --show-channels $peer_ifname > /dev/null 2>&1; then
echo "veth not support multi channels: peer_ifname $peer_ifname"
is_error=true
break
fi
break
done
netif_delete $ifname
netif_delete $peer_ifname
if [ "$is_error" == "true" ]; then
return 1
fi
return 0
}veth 网口多队列支持在 Linux v5.15 版本中引入, 相关提交为 4752eeb3d891c27905a8fdf4d80e899c0efd4ec7.
VXLAN 的组件名称为 vxlan, 相关内核选项为
# Device Drivers
# -> Network device support
# -> Network core driver support
# -> Virtual eXtensible Local Area Network (VXLAN)
CONFIG_VXLAN=y检查工具为
#!/opt/sum/bin/bash
source ./cmd_utils.sh
source ./kernel_config_utils.sh
source ./net_utils.sh
vxlan_check() {
if ! kernel_config_check CONFIG_VXLAN vxlan; then
return 1
fi
ifname="dodo"
netif_delete $ifname
if ! ${IP_CMD} link add $ifname type vxlan id 66 group 239.1.1.1 dev lo dstport 4789; then
echo "create tun failed"
return 1
fi
if ! netif_check $ifname; then
echo "netif not exist: ifname $ifname"
return 1
fi
netif_delete $ifname
return 0
}以太网桥接的组件名称为 ethernet_bridging, 相关内核选项为
# Networking support
# -> Networking options
# -> 802.1d Ethernet Bridging
CONFIG_BRIDGE=y检查工具为
#!/opt/sum/bin/bash
source ./cmd_utils.sh
source ./kernel_config_utils.sh
source ./net_utils.sh
ethernet_bridging_check() {
local is_error
is_error="false"
if ! kernel_config_check CONFIG_BRIDGE bridge; then
return 1
fi
local ifname="dodo"
local p1_ifname="lala"
local p1p_ifname="${p1_ifname}p"
local p2_ifname="xixi"
local p2p_ifname="${p2_ifname}p"
local ns="ns0"
local p1_ns="ns1"
local p2_ns="ns2"
netif_delete $ifname
netif_delete $p1_ifname
netif_delete $p2_ifname
while true; do
if ! ${IP_CMD} link add name $ifname type bridge; then
echo "create bridge failed"
is_error="true"
break
fi
if ! netif_check $ifname; then
echo "netif not exist: ifname $ifname"
is_error="true"
break
fi
if ! ${IP_CMD} netns add $p1_ns; then
echo "add netns failed: p1_ns '$p1_ns'"
is_error="true"
break
fi
if ! ${IP_CMD} netns add $p2_ns; then
echo "add netns failed: p2_ns '$p2_ns'"
is_error="true"
break
fi
if ! netif_veth_new $p1_ifname $p1p_ifname; then
is_error="true"
break
fi
if ! netif_veth_new $p2_ifname $p2p_ifname; then
is_error="true"
break
fi
local p1_ip="192.168.66.1"
local p2_ip="192.168.66.2"
local netmask_len="24"
if ! ${IP_CMD} link set $ifname up; then
echo "set netif up failed: ifname '$ifname'"
is_error=true
break
fi
if ! ${IP_CMD} link set $p1_ifname netns $p1_ns; then
echo "set netif netns failed: p1_ifname '$p1_ifname', p1_ns '$p1_ns'"
is_error="true"
break
fi
if ! ${IP_CMD} netns exec $p1_ns ${IP_CMD} link set $p1_ifname up; then
echo "set netif up failed: p1_ifname '$p1_ifname'"
is_error=true
break
fi
if ! ${IP_CMD} netns exec $p1_ns ${IP_CMD} address add $p1_ip/$netmask_len dev $p1_ifname; then
echo "add netif address failed: peer_ifname '$peer_ifname'"
is_error=true
break
fi
if ! ${IP_CMD} link set $p1p_ifname up; then
echo "set netif up failed: p1p_ifname '$p1p_ifname'"
is_error=true
break
fi
if ! ${IP_CMD} link set $p1p_ifname master $ifname; then
echo "set netif master failed: p1p_ifname '$p1p_ifname', master '$ifname'"
is_error=true
break
fi
if ! ${IP_CMD} link set $p2_ifname netns $p2_ns; then
echo "set netif netns failed: p2_ifname '$p2_ifname', p2_ns '$p2_ns'"
is_error="true"
break
fi
if ! ${IP_CMD} netns exec $p2_ns ${IP_CMD} link set $p2_ifname up; then
echo "set netif up failed: p2_ifname '$p2_ifname'"
is_error=true
break
fi
if ! ${IP_CMD} netns exec $p2_ns ${IP_CMD} address add $p2_ip/$netmask_len dev $p2_ifname; then
echo "add netif address failed: peer_ifname '$peer_ifname'"
is_error=true
break
fi
if ! ${IP_CMD} link set $p2p_ifname up; then
echo "set netif up failed: p2p_ifname '$p2p_ifname'"
is_error=true
break
fi
if ! ${IP_CMD} link set $p2p_ifname master $ifname; then
echo "set netif master failed: p2p_ifname '$p2p_ifname', master '$ifname'"
is_error=true
break
fi
if ! ${IP_CMD} netns exec $p1_ns ${PING_CMD} -I $p1_ifname -c 1 -W 1 $p2_ip > /dev/null; then
echo "ping peer timeout: p1_ifname '$p1_ifname', p2_ip '$p2_ip'"
is_error=true
break
fi
break
done
netif_delete $ifname
netif_delete $p1_ifname
netif_delete $p2_ifname
${IP_CMD} netns del $p1_ns &> /dev/null
${IP_CMD} netns del $p2_ns &> /dev/null
if [ "$is_error" == "true" ]; then
return 1
fi
return 0
}macvlan 的组件名称为 macvlan, 相关内核选项为
# Device Drivers
# -> Network device support
# -> Network core driver support
# -> MAC-VLAN support
CONFIG_MACVLAN=y检查工具为
#!/opt/sum/bin/bash
source ./kernel_config_utils.sh
macvlan_check() {
if ! kernel_config_check CONFIG_MACVLAN macvlan; then
return 1
fi
return 0
}拨号上网的组件名称为 ppp, 相关内核选项为
# Device Drivers
# -> Network device support
# -> Network core driver support
# -> PPP (point-to-point protocol) support
CONFIG_PPP=y
# Device Drivers
# -> Network device support
# -> Network core driver support
# -> PPP (point-to-point protocol) support
# -> PPP over Ethernet
CONFIG_PPPOE=y检查工具为
#!/bin/bash
source ./kernel_config_utils.sh
ppp_check() {
local is_error
is_error="false"
if ! kernel_config_check CONFIG_PPP ppp_generic; then
is_error="true"
fi
if ! kernel_config_check CONFIG_PPPOE pppoe; then
is_error="true"
fi
if [ "$is_error" == "true" ]; then
return 1
fi
return 0
}