wanting to modify lo and unable to ignore #135

Closed
opened 2025-11-15 23:47:42 +01:00 by vklimovs · 3 comments

Upgraded to 2.1 and seeing following behavior. After applying settings ifstate continues to want to modify "lo":

configure network namespaces...

configure sysctl settings...
   ipv6/optimistic_dad               ok

configure interfaces...
 lo
   link                              ok
   addresses                         = 127.0.0.1/8
   addresses                         - ::1/128
   addresses                         + ::1/128
 enp1s0
   link                              ok
   addresses                         = 192.168.2.38/30

configure routing...
   main                              = 0.0.0.0/0

Adding ^lo$ to ignore ifname does not help:

parameters:
  ignore:
    ifname:
      - ^lo$

Explicitely configuring lo also does not work:
interfaces: lo: addresses: - address: ::1/128 scope: host

leads to the same behaviour. There should be a way to apply settings without diff being shown, either by ignoring lo or explicitely configuring it to match system.

Upgraded to 2.1 and seeing following behavior. After applying settings ifstate continues to want to modify "lo": ``` configure network namespaces... configure sysctl settings... ipv6/optimistic_dad ok configure interfaces... lo link ok addresses = 127.0.0.1/8 addresses - ::1/128 addresses + ::1/128 enp1s0 link ok addresses = 192.168.2.38/30 configure routing... main = 0.0.0.0/0 ``` Adding ^lo$ to ignore ifname does not help: ``` parameters: ignore: ifname: - ^lo$ ``` Explicitely configuring lo also does not work: `interfaces: lo: addresses: - address: ::1/128 scope: host ` leads to the same behaviour. There should be a way to apply settings without diff being shown, either by ignoring lo or explicitely configuring it to match system.
Owner

What kernel/distri are you using? I'm not able to reproduce this behavior, yet 🤔

The ignore won't work since ifstate implicitly adds a lo interface definition in every namespace it handles by using these default values:

_default_lo_link = {
'addresses': [
'127.0.0.1/8',
{
'address': '::1/128',
'proto': 1, # kernel_lo
}
],
'link': {
'kind': 'physical',
'state': 'up',
'mtu': 65536,
}
}

Could you please run ifstatecli shell and post the output of pprint(ipr.get_addr(index=1))? Thanks!

What kernel/distri are you using? I'm not able to reproduce this behavior, yet 🤔 The ignore won't work since ifstate implicitly adds a `lo` interface definition in every namespace it handles by using these default values: https://codeberg.org/liske/ifstate/src/commit/bd15566b659157320ec7f5f461a85ccf8a026a96/libifstate/parser/base.py#L23-L36 Could you please run `ifstatecli shell` and post the output of `pprint(ipr.get_addr(index=1))`? Thanks!
liske added this to the 2.1.1 milestone 2025-11-15 23:57:24 +01:00
liske self-assigned this 2025-11-15 23:57:27 +01:00
Author

Thank you for the quick response! Here are the details:

mandrel /etc/ifstate # uname -a
Linux mandrel 6.12.41-gentoo-dist-hardened #1 SMP PREEMPT_DYNAMIC Fri Aug 22 06:32:15 PDT 2025 x86_64 Common KVM processor AuthenticAMD GNU/Linux
mandrel /etc/ifstate # ifstatecli shell
Links:
   1: lo
   2: enp1s0

Symbols:
  ipr = pyroute2.IPRoute()

ifstate 2.1.0; pyroute2 0.9.2
>>> pprint(ipr.get_addr(index=1))
[{'attrs': [('IFA_ADDRESS', '127.0.0.1'),
            ('IFA_LOCAL', '127.0.0.1'),
            ('IFA_BROADCAST', '127.255.255.255'),
            ('IFA_LABEL', 'lo'),
            ('IFA_FLAGS', 128),
            ('IFA_CACHEINFO', {'ifa_preferred': 4294967295, 'ifa_valid': 4294967295, 'cstamp': 532, 'tstamp': 532})],
  'event': 'RTM_NEWADDR',
  'family': 2,
  'flags': 128,
  'header': {'error': None,
             'flags': 2,
             'length': 84,
             'pid': 8352,
             'sequence_number': 256,
             'stats': Stats(qsize=0, delta=0, delay=0),
             'target': 'localhost',
             'type': 20},
  'index': 1,
  'prefixlen': 8,
  'scope': 254},
 {'attrs': [('IFA_ADDRESS', '::1'),
            ('IFA_CACHEINFO', {'ifa_preferred': 4294967295, 'ifa_valid': 4294967295, 'cstamp': 134159, 'tstamp': 134159}),
            ('IFA_FLAGS', 128)],
  'event': 'RTM_NEWADDR',
  'family': 10,
  'flags': 128,
  'header': {'error': None,
             'flags': 2,
             'length': 72,
             'pid': 8352,
             'sequence_number': 256,
             'stats': Stats(qsize=0, delta=0, delay=0),
             'target': 'localhost',
             'type': 20},
  'index': 1,
  'prefixlen': 128,
  'scope': 254}]
Thank you for the quick response! Here are the details: ``` mandrel /etc/ifstate # uname -a Linux mandrel 6.12.41-gentoo-dist-hardened #1 SMP PREEMPT_DYNAMIC Fri Aug 22 06:32:15 PDT 2025 x86_64 Common KVM processor AuthenticAMD GNU/Linux ``` ``` mandrel /etc/ifstate # ifstatecli shell Links: 1: lo 2: enp1s0 Symbols: ipr = pyroute2.IPRoute() ifstate 2.1.0; pyroute2 0.9.2 >>> pprint(ipr.get_addr(index=1)) [{'attrs': [('IFA_ADDRESS', '127.0.0.1'), ('IFA_LOCAL', '127.0.0.1'), ('IFA_BROADCAST', '127.255.255.255'), ('IFA_LABEL', 'lo'), ('IFA_FLAGS', 128), ('IFA_CACHEINFO', {'ifa_preferred': 4294967295, 'ifa_valid': 4294967295, 'cstamp': 532, 'tstamp': 532})], 'event': 'RTM_NEWADDR', 'family': 2, 'flags': 128, 'header': {'error': None, 'flags': 2, 'length': 84, 'pid': 8352, 'sequence_number': 256, 'stats': Stats(qsize=0, delta=0, delay=0), 'target': 'localhost', 'type': 20}, 'index': 1, 'prefixlen': 8, 'scope': 254}, {'attrs': [('IFA_ADDRESS', '::1'), ('IFA_CACHEINFO', {'ifa_preferred': 4294967295, 'ifa_valid': 4294967295, 'cstamp': 134159, 'tstamp': 134159}), ('IFA_FLAGS', 128)], 'event': 'RTM_NEWADDR', 'family': 10, 'flags': 128, 'header': {'error': None, 'flags': 2, 'length': 72, 'pid': 8352, 'sequence_number': 256, 'stats': Stats(qsize=0, delta=0, delay=0), 'target': 'localhost', 'type': 20}, 'index': 1, 'prefixlen': 128, 'scope': 254}] ```
Owner

Thanks, the IFA_PROTO is missing for ::1. So ifstate removes the IP and adds it again with the proto with no avail.

I observed a simular issue with IFA_PROTO on kernel generated IPv6 mod. EUI64 LLA (while it works on several other). So I'm going to just drop the proto from the _default_lo_link for now as it is not reliable.

Thanks, the `IFA_PROTO` is missing for `::1`. So ifstate removes the IP and adds it again with the proto with no avail. I observed a simular issue with `IFA_PROTO` on kernel generated IPv6 mod. EUI64 LLA (while it works on several other). So I'm going to just drop the proto from the `_default_lo_link` for now as it is not reliable.
liske closed this issue 2025-11-17 06:43:25 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
liske/ifstate#135
No description provided.