From 28e019aa5c5ecb31ad54b48cfe848d415cae1584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Wed, 2 Sep 2026 12:38:26 -0300 Subject: [PATCH] fix(ppcmac): validate network addresses with isValidIp validate_ip accepted any all-zero address. Only the gateway may be all zeros, which lpar_netboot uses when no router is needed. --- perl-xCAT/xCAT/PPCmac.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/perl-xCAT/xCAT/PPCmac.pm b/perl-xCAT/xCAT/PPCmac.pm index 75b11ee0f..6ceb50a4e 100644 --- a/perl-xCAT/xCAT/PPCmac.pm +++ b/perl-xCAT/xCAT/PPCmac.pm @@ -114,8 +114,7 @@ sub parse_args { } else { $server = xCAT::ServiceNodeUtils->getSNformattedhash($node, "xcat", "node", "primary"); foreach my $key (keys %$server) { - my $valid_ip = xCAT::NetworkUtils->validate_ip($key); - if ($valid_ip) { + unless (xCAT::NetworkUtils->isValidIp($key)) { ################################################### # Service node is returned as hostname, Convert # hostname to IP @@ -224,9 +223,13 @@ sub parse_args { if (scalar(@network) != 3) { return (usage()); } - my $result = xCAT::NetworkUtils->validate_ip($opt{C}, $opt{G}, $opt{S}); - if (@$result[0]) { - return (usage(@$result[1])); + foreach my $key (qw(C G S)) { + my $ip = $opt{$key}; + + # lpar_netboot accepts an all-zero gateway when no router is needed + next if $key eq 'G' and $ip eq '0.0.0.0'; + next if xCAT::NetworkUtils->isValidIp($ip); + return (usage("Invalid IP address: $ip")); } } } elsif ((exists($opt{S}) || exists($opt{G}) || exists($opt{C})) && !exists($opt{D})) {