summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzdc <zdc@users.noreply.github.com>2023-01-03 17:34:59 +0200
committerGitHub <noreply@github.com>2023-01-03 17:34:59 +0200
commit49dd3dc21d7069c1934541c05ecb2201bd8313a2 (patch)
treea2c189dc38a632fbaafdc8972a0412ea4f6fa73f
parent2bc88186b952e32bcf26419af2563c6f1bd7daac (diff)
parent1636db20ee4b3d388a25b62e86bea1de52fcc339 (diff)
downloadvyatta-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-xlib/Vyatta/IpTables/IpSet.pm12
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;
}