diff options
author | zdc <zdc@users.noreply.github.com> | 2023-01-03 17:34:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-03 17:34:59 +0200 |
commit | 49dd3dc21d7069c1934541c05ecb2201bd8313a2 (patch) | |
tree | a2c189dc38a632fbaafdc8972a0412ea4f6fa73f | |
parent | 2bc88186b952e32bcf26419af2563c6f1bd7daac (diff) | |
parent | 1636db20ee4b3d388a25b62e86bea1de52fcc339 (diff) | |
download | vyatta-cfg-firewall-49dd3dc21d7069c1934541c05ecb2201bd8313a2.tar.gz vyatta-cfg-firewall-49dd3dc21d7069c1934541c05ecb2201bd8313a2.zip |
Merge pull request #35 from zdc/T4869-equuleus1.3.61.3.51.3.41.3.3-epa11.3.3
network-groups: T4869: Fixed operations with /32 and /128 netmasks
-rwxr-xr-x | lib/Vyatta/IpTables/IpSet.pm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Vyatta/IpTables/IpSet.pm b/lib/Vyatta/IpTables/IpSet.pm index be50472..a7fccb7 100755 --- a/lib/Vyatta/IpTables/IpSet.pm +++ b/lib/Vyatta/IpTables/IpSet.pm @@ -420,7 +420,19 @@ sub members_list { } # parse the output otherwise my $parsed_out = XML::LibXML->load_xml(string => $ipset_output); + my $set_type = $parsed_out->findvalue('/ipsets/ipset/type'); + my $set_family = $parsed_out->findvalue('/ipsets/ipset/header/family'); foreach my $node ($parsed_out->findnodes('/ipsets/ipset/members/member/elem/text()')) { + # modify networks with /32 and /128 netmasks to match CLI items later + # an example: '192.0.2.0' -> '192.0.2.0/32', '2001:db8::' -> '2001:db8::/128' + if ($set_type eq 'hash:net') { + if (($set_family eq 'inet') and ($node !~ /.*\/\d+/ )) { + $node = "${node}/32"; + } + if (($set_family eq 'inet6') and ($node !~ /.*\/\d+/ )) { + $node = "${node}/128"; + } + } $elements_list{$node} = undef; } |