- Begin veth support...
This commit is contained in:
@@ -124,7 +124,7 @@ network_dst_tab_load()
|
||||
ndtl_host_name="vpn${ndtl_id}.vpn.rx3"
|
||||
|
||||
tab_assign NETWORK_DST_TAB "${ndtl_id},Host_Name" "${ndtl_host_name}"
|
||||
dns_lookup A "${ndtl_host_name}" "NOCACHE"
|
||||
dns_lookup "A" "${ndtl_host_name}" "NOCACHE"
|
||||
tab_assign NETWORK_DST_TAB "${ndtl_id},IP" "${dns_value}"
|
||||
|
||||
case "${ndtl_type}"
|
||||
@@ -191,7 +191,6 @@ network_dst_tab_get()
|
||||
dst_bytes_sent=${NETWORK_DST_TAB["${dst_id},Bytes_Sent"]}
|
||||
dst_start_date=${NETWORK_DST_TAB["${dst_id},Start_Date"]}
|
||||
dst_uptime=${NETWORK_DST_TAB["${dst_id},Uptime"]}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -568,6 +567,111 @@ network_table_set()
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# veth_up
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function veth_up
|
||||
{
|
||||
vu_eth_dev_eth=$1
|
||||
vu_peer_dev=$2
|
||||
vu_eth_addr=$3
|
||||
vu_eth_mask=$4
|
||||
vu_peer_addr=$5
|
||||
vu_table=$6
|
||||
|
||||
|
||||
${LOG} "Create veth pair [${vu_eth_dev}]/[${vu_peer_dev}]..."
|
||||
|
||||
${DEBUG} ip link add ${vu_eth_dev} type veth peer name ${vu_peer_dev}
|
||||
|
||||
|
||||
${LOG} "Configure host side [${vu_eth_dev}:${vu_eth_addr}/${vu_eth_mask}]..."
|
||||
|
||||
${DEBUG} ip link set ${vu_eth_dev} up
|
||||
${DEBUG} ip addr add ${vu_eth_addr}/${vu_eth_mask} dev ${vu_eth_dev}
|
||||
|
||||
|
||||
${LOG} "Configure IP rule and routing..."
|
||||
|
||||
${DEBUG} ip rule add from ${vu_peer_addr} table ${vu_table}
|
||||
|
||||
|
||||
TABLE_LIST=${vu_table}
|
||||
|
||||
vu_route="$(ip route list table main | grep -e ${vu_eth_dev} | grep -e ${vu_eth_addr} | sed 's/ proto.*//')"
|
||||
for vu_tab in ${TABLE_LIST}
|
||||
do
|
||||
${DEBUG} ip route add ${vu_route} table ${vu_tab}
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# veth_down
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function veth_down
|
||||
{
|
||||
vd_eth_dev_eth=$1
|
||||
vd_peer_dev=$2
|
||||
vd_eth_addr=$3
|
||||
vd_eth_mask=$4
|
||||
vd_peer_addr=$5
|
||||
vd_table=$6
|
||||
|
||||
|
||||
${LOG} "Remove IP routing and rule..."
|
||||
|
||||
TABLE_LIST=${vd_table}
|
||||
|
||||
vd_route="$(ip route list table main | grep -e ${vd_eth_dev} | grep -e ${vd_eth_addr} | sed 's/ proto.*//')"
|
||||
for tab in ${TABLE_LIST}
|
||||
do
|
||||
${DEBUG} ip route show ${vd_route} table ${tab} &> /dev/null && ${DEBUG} ip route del ${route} table ${tab} &> /dev/null || true
|
||||
done
|
||||
|
||||
${DEBUG} ip rule del from ${vd_peer_addr} &> /dev/null || true
|
||||
|
||||
|
||||
${LOG} "Remove veth pair..."
|
||||
|
||||
${DEBUG} ip link show ${vd_eth_dev} &> /dev/null && ${DEBUG} ip link del ${vd_eth_dev} &> /dev/null
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# network_veth_init
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
network_veth_init()
|
||||
{
|
||||
${LOG} "Add VEth"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# network_veth_deinit
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
network_veth_deinit()
|
||||
{
|
||||
${LOG} "Remove VEth"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# network_forward_add
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -691,6 +795,40 @@ network_forward_stop()
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# network_start
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
network_start()
|
||||
{
|
||||
network_table_init
|
||||
|
||||
network_veth_init
|
||||
|
||||
network_forward_start
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# network_stop
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
network_stop()
|
||||
{
|
||||
network_forward_stop
|
||||
|
||||
network_veth_deinit
|
||||
|
||||
network_table_deinit
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# network_status
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user