l3cfg: implement NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE and rework object state

NML3Cfg tracks state about all addresses/routes. It needs that (at
least) for the following reaons:

1) if a address/route gets added by NetworkManager and then gets
  externally removed then it is presumed that the user did this. In this
  case, we remember that ("externally-removed") to not re-add the
  address/route, until we do a full reapply. This was previously
  tracked as "externally_removed_objs_hash".

2) when NML3Cfg configures a address/route in kernel, and later the
  address/route is no longer to be configured, then NML3Cfg needs to
  delete it again. It thus needs to remember which addresses/routes
  it configured earlier to remove them. This was previously tracked via
  "last_addresses_x" and "last_routes_x".

3) kernel rejects configuring certain routes while a related IPv6
  address is still tentative. That means, NML3Cfg needs to detect that,
  remember it, and retry later. That is previously tracked as
  "routes_temporary_not_available_hash".

4) during NM_L3_CFG_COMMIT_TYPE_ASSUME, we don't remove extraneous
  and don't add missing addresses/routes. This commit mode is done
  while assuming a device, that is, gracefully taking over after
  a restart. However, sometimes while assuming a device we forcefully
  want to configure an address/route. That happens for example if we
  do IPv6 link local addressing. Then we really want to add that
  address/route, even in assume mode. That is what the
  NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE flag does, and to implement
  that we need to track whether we already tried to add the
  address/route previously. This is something new.

Consolidate these various states in a new "obj_state_hash" and
"ObjStateData" structure. This solves above points the following way:

1) to track externally removed objects, we have a flag in ObjStateData
  that indicates whether the object was every configured and whether
  it currently is configured. Based on that we make decisions to
  configure (or not) an address. See "_obj_states_sync_filter()".

2) we now mark objects that NML3Cfg configured, which are still in platform
  and which are no longer to be configured as "zombies".

3) this is now tracked via ObjStateData's "os_temporary_not_available_lst".

4) with the available ObjStateData we can make appropriate decisions
  in "_obj_states_sync_filter()".
This commit is contained in:
Thomas Haller 2021-09-06 15:06:15 +02:00
parent 8a3d913de8
commit 929eae245d
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

File diff suppressed because it is too large Load diff