@@ -1485,11 +1485,20 @@ def _add_ebtable_rules_for_vfnics(dhcpInfo):
14851485 CHAIN_NAME = getDhcpEbtableChainName (dhcp_ip )
14861486 VF_NIC_MAC = ip .removeZeroFromMacAddress (dhcpInfo .mac )
14871487
1488- if bash_r (EBTABLES_CMD + " -L {{CHAIN_NAME}} | grep -- '-p IPv4 -s {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT' > /dev/null" ) != 0 :
1489- bash_r (EBTABLES_CMD + ' -I {{CHAIN_NAME}} -p IPv4 -s {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT ' )
1488+ if bash_r (EBTABLES_CMD + ' -L ZSTACK-VF-DHCP > /dev/null 2>&1' ) != 0 :
1489+ bash_errorout (EBTABLES_CMD + ' -N ZSTACK-VF-DHCP ' )
14901490
1491- if bash_r (EBTABLES_CMD + " -L {{CHAIN_NAME}} | grep -- '-p IPv4 -d {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT' > /dev/null" ) != 0 :
1492- bash_r (EBTABLES_CMD + ' -I {{CHAIN_NAME}} -p IPv4 -d {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT' )
1491+ if bash_r (EBTABLES_CMD + " -L FORWARD | grep -- '-j ZSTACK-VF-DHCP' > /dev/null" ) != 0 :
1492+ bash_r (EBTABLES_CMD + ' -I FORWARD -j ZSTACK-VF-DHCP' )
1493+
1494+ if bash_r (EBTABLES_CMD + " -L ZSTACK-VF-DHCP | grep -- '-j RETURN' > /dev/null" ) != 0 :
1495+ bash_r (EBTABLES_CMD + ' -A ZSTACK-VF-DHCP -j RETURN' )
1496+
1497+ if bash_r (EBTABLES_CMD + " -L ZSTACK-VF-DHCP | grep -- '-p IPv4 -s {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT' > /dev/null" ) != 0 :
1498+ bash_r (EBTABLES_CMD + ' -I ZSTACK-VF-DHCP -p IPv4 -s {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT' )
1499+
1500+ if bash_r (EBTABLES_CMD + " -L ZSTACK-VF-DHCP | grep -- '-p IPv4 -d {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT' > /dev/null" ) != 0 :
1501+ bash_r (EBTABLES_CMD + ' -I ZSTACK-VF-DHCP -p IPv4 -d {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT' )
14931502
14941503 @in_bash
14951504 def apply (dhcp ):
@@ -1878,8 +1887,8 @@ def _remove_ebtable_rules_for_vfnics(dhcpInfo):
18781887 if dhcp_ip :
18791888 CHAIN_NAME = getDhcpEbtableChainName (dhcp_ip )
18801889 VF_NIC_MAC = dhcpInfo .mac
1881- bash_r (EBTABLES_CMD + ' -D {{CHAIN_NAME}} -p IPv4 -s {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT' )
1882- bash_r (EBTABLES_CMD + ' -D {{CHAIN_NAME}} -p IPv4 -d {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT' )
1890+ bash_r (EBTABLES_CMD + ' -D ZSTACK-VF-DHCP -p IPv4 -s {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT' )
1891+ bash_r (EBTABLES_CMD + ' -D ZSTACK-VF-DHCP -p IPv4 -d {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT' )
18831892
18841893 @in_bash
18851894 def release (dhcp ):
0 commit comments