Skip to content

Commit 8b79f7f

Browse files
Merge pull request #1043
compat-suse: use iftype in sysctl handling (bsc#1230911)
2 parents 172cc3e + 5b28358 commit 8b79f7f

File tree

4 files changed

+346
-98
lines changed

4 files changed

+346
-98
lines changed

client/suse/compat-suse.c

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6471,45 +6471,52 @@ ni_suse_ifcfg_parse_firewall(ni_suse_ifcfg_array_t *ifcfgs, ni_suse_ifcfg_t *ifc
64716471
return TRUE;
64726472
}
64736473

6474-
/*
6475-
* Read ifsysctl file
6476-
*/
64776474
static const ni_var_t *
6478-
__ifsysctl_get_var(ni_var_array_t *vars, const char *path, const char *ifname, const char *attr)
6475+
ni_suse_ifsysctl_get_var(ni_var_array_t *vars, const char *path, ni_netdev_t *dev,
6476+
const char *attr)
64796477
{
6480-
const char *def_names[] = { "all", "default", ifname, NULL };
6481-
const char *lo_names[] = { ifname, NULL };
6482-
const char **names = ni_string_eq(ifname, "lo") ? lo_names : def_names;
6483-
const char **name;
6484-
const ni_var_t *ret = NULL;
6478+
const char *all[] = { dev->name, "default", "all", NULL };
6479+
const char *ifc_only[] = { dev->name, NULL };
6480+
const char **names = all;
6481+
const char **name = NULL;
64856482
const ni_var_t *var;
64866483

6484+
if (ni_string_eq(attr, "accept_redirects") ||
6485+
ni_string_eq(attr, "use_tempaddr")) {
6486+
if (dev->link.type == NI_IFTYPE_LOOPBACK)
6487+
return NULL;
6488+
}
6489+
6490+
if (ni_string_eq(attr, "accept_redirects"))
6491+
names = ifc_only;
6492+
64876493
for (name = names; *name; name++) {
64886494
var = ni_ifsysctl_vars_get(vars, "%s/%s/%s", path, *name, attr);
64896495
if (!var || ni_string_empty(var->value))
64906496
continue;
6491-
ret = var;
6497+
return var;
64926498
}
6493-
return ret;
6499+
6500+
return NULL;
64946501
}
64956502

64966503
static const char *
6497-
__ifsysctl_get_str(ni_var_array_t *vars, const char *path, const char *ifname, const char *attr)
6504+
ni_suse_ifsysctl_get_str(ni_var_array_t *vars, const char *path, ni_netdev_t *dev, const char *attr)
64986505
{
64996506
const ni_var_t *var;
65006507

6501-
if ((var = __ifsysctl_get_var(vars, path, ifname, attr)))
6508+
if ((var = ni_suse_ifsysctl_get_var(vars, path, dev, attr)))
65026509
return var->value;
65036510
return NULL;
65046511
}
65056512

65066513
static ni_bool_t
6507-
__ifsysctl_get_int(ni_var_array_t *vars, const char *path, const char *ifname,
6514+
ni_suse_ifsysctl_get_int(ni_var_array_t *vars, const char *path, ni_netdev_t *dev,
65086515
const char *attr, int *value, int base)
65096516
{
65106517
const ni_var_t *var;
65116518

6512-
if (!(var = __ifsysctl_get_var(vars, path, ifname, attr)))
6519+
if (!(var = ni_suse_ifsysctl_get_var(vars, path, dev, attr)))
65136520
return FALSE;
65146521

65156522
if (ni_parse_int(var->value, value, base) < 0) {
@@ -6524,13 +6531,13 @@ __ifsysctl_get_int(ni_var_array_t *vars, const char *path, const char *ifname,
65246531
}
65256532

65266533
static ni_bool_t
6527-
__ifsysctl_get_ipv6(ni_var_array_t *vars, const char *path, const char *ifname,
6534+
ni_suse_ifsysctl_get_ipv6(ni_var_array_t *vars, const char *path, ni_netdev_t *dev,
65286535
const char *attr, struct in6_addr *ipv6)
65296536
{
65306537
ni_sockaddr_t addr;
65316538
const char *str;
65326539

6533-
str = __ifsysctl_get_str(vars, path, ifname, attr);
6540+
str = ni_suse_ifsysctl_get_str(vars, path, dev, attr);
65346541
if (!str || ni_sockaddr_parse(&addr, str, AF_INET6) < 0)
65356542
return FALSE;
65366543

@@ -6539,12 +6546,12 @@ __ifsysctl_get_ipv6(ni_var_array_t *vars, const char *path, const char *ifname,
65396546
}
65406547

65416548
static void
6542-
__ifsysctl_get_tristate(ni_var_array_t *vars, const char *path, const char *ifname,
6549+
ni_suse_ifsysctl_get_tristate(ni_var_array_t *vars, const char *path, ni_netdev_t *dev,
65436550
const char *attr, ni_tristate_t *tristate)
65446551
{
65456552
int value = NI_TRISTATE_DEFAULT;
65466553

6547-
__ifsysctl_get_int(vars, path, ifname, attr, &value, 10);
6554+
ni_suse_ifsysctl_get_int(vars, path, dev, attr, &value, 10);
65486555
if (ni_tristate_is_set(value))
65496556
ni_tristate_set(tristate, value);
65506557
}
@@ -6564,13 +6571,18 @@ ni_suse_ifcfg_parse_ifsysctl_ipv4(ni_suse_ifcfg_t *ifcfg, ni_var_array_t *ifsysc
65646571
if (!(ipv4 = ni_netdev_get_ipv4(dev)))
65656572
return FALSE;
65666573

6567-
/* Note: no conf.enable and conf.arp-verify in sysctl */
6574+
/* There is no conf.enabled in sysctl, let's assume TRUE as default.
6575+
* This also gives us the <interface><ipv4><enabled> node always. */
6576+
ni_tristate_set(&ipv4->conf.enabled, TRUE);
6577+
6578+
/* Note: No conf.arp-verify in sysctl, can be set with CHECK_DUPLICATE_IP */
65686579

6569-
__ifsysctl_get_tristate(ifsysctl, "net/ipv4/conf", dev->name,
6580+
ni_suse_ifsysctl_get_tristate(ifsysctl, "net/ipv4/conf", dev,
65706581
"forwarding", &ipv4->conf.forwarding);
6571-
__ifsysctl_get_tristate(ifsysctl, "net/ipv4/conf", dev->name,
6582+
/* Note: arp_notify is also set with SEND_GRATUITOUS_ARP */
6583+
ni_suse_ifsysctl_get_tristate(ifsysctl, "net/ipv4/conf", dev,
65726584
"arp_notify", &ipv4->conf.arp_notify);
6573-
__ifsysctl_get_tristate(ifsysctl, "net/ipv4/conf", dev->name,
6585+
ni_suse_ifsysctl_get_tristate(ifsysctl, "net/ipv4/conf", dev,
65746586
"accept_redirects", &ipv4->conf.accept_redirects);
65756587

65766588
return TRUE;
@@ -6590,10 +6602,10 @@ ni_suse_ifcfg_parse_ifsysctl_ipv6(ni_suse_ifcfg_t *ifcfg, ni_var_array_t *ifsysc
65906602
* First, get sysctl's affecting also "IPv6 L2" aka
65916603
* stable secret for the fe80 link-address assignment.
65926604
*/
6593-
__ifsysctl_get_int(ifsysctl, "net/ipv6/conf", dev->name,
6605+
ni_suse_ifsysctl_get_int(ifsysctl, "net/ipv6/conf", dev,
65946606
"addr_gen_mode", &ipv6->conf.addr_gen_mode, 10);
65956607

6596-
__ifsysctl_get_ipv6(ifsysctl, "net/ipv6/conf", dev->name,
6608+
ni_suse_ifsysctl_get_ipv6(ifsysctl, "net/ipv6/conf", dev,
65976609
"stable_secret", &ipv6->conf.stable_secret);
65986610

65996611
/*
@@ -6605,57 +6617,60 @@ ni_suse_ifcfg_parse_ifsysctl_ipv6(ni_suse_ifcfg_t *ifcfg, ni_var_array_t *ifsysc
66056617
if (ifcfg->l2only)
66066618
return TRUE;
66076619

6620+
/* Set default ipv6 enabled state. without this, we
6621+
* miss the <ipv6><enabled> node */
6622+
ni_tristate_set(&ipv6->conf.enabled, !__ni_ipv6_disbled);
6623+
66086624
/*
66096625
* When IPv6 is disabled via kernel cmdline, we're done
66106626
* TODO: it's wrong to mix kernel cmdline overrides into
66116627
* config parsing and we've to remove this and handle
66126628
* later at runtime while applying the config.
66136629
*/
6614-
if (__ni_ipv6_disbled) {
6615-
ni_tristate_set(&ipv6->conf.enabled, FALSE);
6630+
if (__ni_ipv6_disbled)
66166631
return TRUE;
6617-
}
6632+
66186633

66196634
/*
66206635
* When IPv6 is disabled via sysctl, we're done
66216636
*/
6622-
__ifsysctl_get_tristate(ifsysctl, "net/ipv6/conf", dev->name,
6637+
ni_suse_ifsysctl_get_tristate(ifsysctl, "net/ipv6/conf", dev,
66236638
"disable_ipv6", &disable_ipv6);
66246639
if (ni_tristate_is_set(disable_ipv6))
66256640
ni_tristate_set(&ipv6->conf.enabled, !disable_ipv6);
66266641
if (ni_tristate_is_disabled(ipv6->conf.enabled))
66276642
return TRUE;
66286643

6629-
__ifsysctl_get_tristate(ifsysctl, "net/ipv6/conf", dev->name,
6644+
ni_suse_ifsysctl_get_tristate(ifsysctl, "net/ipv6/conf", dev,
66306645
"forwarding", &ipv6->conf.forwarding);
66316646

6632-
__ifsysctl_get_int(ifsysctl, "net/ipv6/conf", dev->name,
6647+
ni_suse_ifsysctl_get_int(ifsysctl, "net/ipv6/conf", dev,
66336648
"accept_ra", &ipv6->conf.accept_ra, 10);
66346649
if (ipv6->conf.accept_ra > NI_IPV6_ACCEPT_RA_ROUTER)
66356650
ipv6->conf.accept_ra = NI_IPV6_ACCEPT_RA_ROUTER;
66366651
else
66376652
if (ipv6->conf.accept_ra < NI_IPV6_ACCEPT_RA_DEFAULT)
66386653
ipv6->conf.accept_ra = NI_IPV6_ACCEPT_RA_DEFAULT;
66396654

6640-
__ifsysctl_get_int(ifsysctl, "net/ipv6/conf", dev->name,
6655+
ni_suse_ifsysctl_get_int(ifsysctl, "net/ipv6/conf", dev,
66416656
"accept_dad", &ipv6->conf.accept_dad, 10);
66426657
if (ipv6->conf.accept_dad > NI_IPV6_ACCEPT_DAD_FAIL_PROTOCOL)
66436658
ipv6->conf.accept_dad = NI_IPV6_ACCEPT_DAD_FAIL_PROTOCOL;
66446659
else
66456660
if (ipv6->conf.accept_dad < NI_IPV6_ACCEPT_DAD_DEFAULT)
66466661
ipv6->conf.accept_dad = NI_IPV6_ACCEPT_DAD_DEFAULT;
66476662

6648-
__ifsysctl_get_tristate(ifsysctl, "net/ipv6/conf", dev->name,
6663+
ni_suse_ifsysctl_get_tristate(ifsysctl, "net/ipv6/conf", dev,
66496664
"autoconf", &ipv6->conf.autoconf);
66506665

6651-
__ifsysctl_get_int(ifsysctl, "net/ipv6/conf", dev->name,
6666+
ni_suse_ifsysctl_get_int(ifsysctl, "net/ipv6/conf", dev,
66526667
"use_tempaddr", &ipv6->conf.privacy, 10);
66536668
if (ipv6->conf.privacy > NI_IPV6_PRIVACY_PREFER_TEMPORARY)
66546669
ipv6->conf.privacy = NI_IPV6_PRIVACY_PREFER_TEMPORARY;
66556670
else if (ipv6->conf.privacy < NI_IPV6_PRIVACY_DEFAULT)
66566671
ipv6->conf.privacy = NI_IPV6_PRIVACY_DISABLED;
66576672

6658-
__ifsysctl_get_tristate(ifsysctl, "net/ipv6/conf", dev->name,
6673+
ni_suse_ifsysctl_get_tristate(ifsysctl, "net/ipv6/conf", dev,
66596674
"accept_redirects", &ipv6->conf.accept_redirects);
66606675

66616676
return TRUE;

man/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ generated_in_man = \
3636
ifroute.5 \
3737
ifrule.5 \
3838
ifstatus.8 \
39-
ifsysctl.5 \
4039
ifup.8 \
4140
routes.5 \
4241
wicked-config.5 \
@@ -51,6 +50,7 @@ generated_md_man = \
5150
ifcfg-ipoib.5 \
5251
ifcfg-team.5 \
5352
ifcfg-wireless.5 \
53+
ifsysctl.5 \
5454
wicked-firmware.8 \
5555
wicked-redfish.8
5656

0 commit comments

Comments
 (0)