Skip to content

Commit c783073

Browse files
author
pengchao.liu
committed
<fix>[mevoco]: fix ebtables error
Resolves: ZSTAC-45025 Change-Id: I756670726c786967626a6d747766666a7363616f
1 parent 28b6c9b commit c783073

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

kvmagent/kvmagent/plugins/mevoco.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,11 +1493,20 @@ def _add_ebtable_rules_for_vfnics(dhcpInfo):
14931493
CHAIN_NAME = getDhcpEbtableChainName(dhcp_ip)
14941494
VF_NIC_MAC = ip.removeZeroFromMacAddress(dhcpInfo.mac)
14951495

1496-
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:
1497-
bash_r(EBTABLES_CMD + ' -I {{CHAIN_NAME}} -p IPv4 -s {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT')
1496+
if bash_r(EBTABLES_CMD + ' -L ZSTACK-VF-DHCP > /dev/null 2>&1') != 0:
1497+
bash_errorout(EBTABLES_CMD + ' -N ZSTACK-VF-DHCP')
14981498

1499-
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:
1500-
bash_r(EBTABLES_CMD + ' -I {{CHAIN_NAME}} -p IPv4 -d {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT')
1499+
if bash_r(EBTABLES_CMD + " -L FORWARD | grep -- '-j ZSTACK-VF-DHCP' > /dev/null") != 0:
1500+
bash_r(EBTABLES_CMD + ' -I FORWARD -j ZSTACK-VF-DHCP')
1501+
1502+
if bash_r(EBTABLES_CMD + " -L ZSTACK-VF-DHCP | grep -- '-j RETURN' > /dev/null") != 0:
1503+
bash_r(EBTABLES_CMD + ' -A ZSTACK-VF-DHCP -j RETURN')
1504+
1505+
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:
1506+
bash_r(EBTABLES_CMD + ' -I ZSTACK-VF-DHCP -p IPv4 -s {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT')
1507+
1508+
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:
1509+
bash_r(EBTABLES_CMD + ' -I ZSTACK-VF-DHCP -p IPv4 -d {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT')
15011510

15021511
@in_bash
15031512
def apply(dhcp):
@@ -1886,8 +1895,8 @@ def _remove_ebtable_rules_for_vfnics(dhcpInfo):
18861895
if dhcp_ip:
18871896
CHAIN_NAME = getDhcpEbtableChainName(dhcp_ip)
18881897
VF_NIC_MAC = dhcpInfo.mac
1889-
bash_r(EBTABLES_CMD + ' -D {{CHAIN_NAME}} -p IPv4 -s {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT')
1890-
bash_r(EBTABLES_CMD + ' -D {{CHAIN_NAME}} -p IPv4 -d {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT')
1898+
bash_r(EBTABLES_CMD + ' -D ZSTACK-VF-DHCP -p IPv4 -s {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT')
1899+
bash_r(EBTABLES_CMD + ' -D ZSTACK-VF-DHCP -p IPv4 -d {{VF_NIC_MAC}} --ip-proto udp --ip-sport 67:68 -j ACCEPT')
18911900

18921901
@in_bash
18931902
def release(dhcp):

0 commit comments

Comments
 (0)