161 Commits

Author SHA1 Message Date
Gris Ge
924e62d55e test: Improve link monitor ip_monitor_assert_stable_link_up
Current thread data sharing and function decorator is hard to understand,
Changed the ip monitor output to a temp file and check it after test finished.

For ethernet or veth, `nmcli c down` will not cause link down, hence
`ip_monitor_assert_stable_link_up()` changed to fail if specified
interface is ethernet or veth.

Changed test case `test_change_mtu_with_stable_link_up` to use linux
bridge instead of veth, so it will fails when nmstate is using normal
connection activation instead of reapply.

Changed test case in `static_ip_address_test.py` to use dummy interface
for link stability tests.

Signed-off-by: Gris Ge <fge@redhat.com>
2024-11-18 22:54:44 +08:00
Íñigo Huguet
b4f1aa6143 route: correctly compare the route's next-hop
In nmstate routes without next-hop are represented with "0.0.0.0" or
"::". This is because we need to differentiate the case "I don't care
about the next-hop for routes matching" (next-hop=None) and "This route
doesn't have next-hop" (next-hop=0.0.0.0).

However, NM doesn't do the same because it doesn't need that
differentiation. If a NM profile contains a direct route, without
next-hop, it will just leave it empty, thus we get next-hop=None.

This causes that comparing an NmIpRoute created from a nmstate route
with an NmIpRoute created from an existing NM profile will fail because
of this difference. Fix it by converting "0.0.0.0" / "::" to None when
creating a NmIpRoute from an nmstate route. This is the right
representation for it at `nm` layer, anyway.

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2024-11-07 19:47:24 +08:00
Gris Ge
6740104d0f test: Remove test_linux_bridge_option_integer_rounded_on_ubuntu_kernel
The github CI has changed the Ubuntu kernel to 6.8.0-1013-azure which is
using 1000 for `CONFIG_HZ`, the test
`test_linux_bridge_option_integer_rounded_on_ubuntu_kernel` will never
raise expected error on 1000HZ kernel.

Considering we can never test it in CI, removing this test case.

Signed-off-by: Gris Ge <fge@redhat.com>
2024-09-19 18:30:58 +08:00
Filip Pokryvka
e2c98d77dd tests.cmdlib: format exception in subprocess
If executed command returns non-zero exitcode with `check=True`, exception
raised by subprocess is not showing stdout/stderr, just returncode, which
is not enough for debug. Raise Exception which prints stdout and stderr
of the executed process.

Signed-off-by: Filip Pokryvka <fpokryvk@redhat.com>
2024-09-12 21:39:41 +08:00
Gris Ge
2207c40b8c gen_conf: Support special route type
Currently the `gen_conf` will discard routes with special
types(blackhole, unreachable, prohibit).

The root cause: `gen_conf` is taking empty network state as current
state lacking loopback interface `lo`, hence routes stored to that
interface will be ignored when generating NetworkManager connection
file.

Fixed by passing default loopback interface as current interface.

Integration test case included.

Resolves: https://issues.redhat.com/browse/RHEL-56727

Signed-off-by: Gris Ge <fge@redhat.com>
2024-09-04 16:18:10 +08:00
Íñigo Huguet
a150aab817 test: don't fail if NetworkManager-libreswan is missing
It is not possible to run integration tests if NetworkManager-libreswan
rpm is not installed. Pytest fails during the collection stage,
preventing from running even tests not related to Libreswan.

Fix it.

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2024-08-05 21:38:02 +08:00
Gris Ge
4866ad525e test: apply_with_description should not modify input dictionary
Use `copy.deepcopy()` instead.

Signed-off-by: Gris Ge <fge@redhat.com>
2024-08-02 12:08:43 +08:00
Gris Ge
92a6eefc45 test: Remove the need of python3-gobject-base
The python3-gobject-base is too big for test container.
Change the test code to use rpm instead to query NetworkManager version.

Signed-off-by: Gris Ge <fge@redhat.com>
2024-06-27 22:02:25 +08:00
Gris Ge
4088e4708c route: Add support of static route in kernel mode
Support add and remove static routes in kernel mode, these are not
supported yet:
 * route table ID bigger than 255
 * route weight
 * route type
 * route cwnd(congestion window)

Integration test case included.

Resolves: https://issues.redhat.com/browse/RHEL-37665

Signed-off-by: Gris Ge <fge@redhat.com>
2024-06-13 10:34:38 +08:00
Gris Ge
af93eee08c test: Fix incorrect version check on NetworkManager-libreswan
Instead of checking micro version, we should convert version to a
integer to compare using this formula:

    10000 * major_version + 100 * minor_version + micro_version

Introduced `nm_libreswan_version_int()` and `version_str_to_int()` for
this and fixed all version check in ipsec test.

Signed-off-by: Gris Ge <fge@redhat.com>
2024-06-12 10:06:07 +08:00
Gris Ge
bf0975ed2b test: Remove overlapping ipsec address pool
Signed-off-by: Gris Ge <fge@redhat.com>
2024-06-05 20:32:13 +08:00
Gris Ge
7a016960a4 test: Add IPv6 ipsec tests
With NetworkManager-libreswan 1.2.22+, IPv6 libreswan ipsec tunnel is
supported.

Integration test cases included.

Resolves: https://issues.redhat.com/browse/RHEL-32279

Signed-off-by: Gris Ge <fge@redhat.com>
2024-06-05 20:32:13 +08:00
Gris Ge
bb9981c730 net_state: Add description to top level YAML/JSON API
Introducing `description` as top level key of YAML/JSON API holding a
String. For example:

```yml
description: Abc
```

Currently, this property will be ignored when applying or querying, no
backend will persist this property. It is designed for user to store
description for the whole YAML only for now.

By using `testlib.apply.apply_with_description()`, we could store:
`test_description: <string>` into `.descriptions`. The
`pytest ----dump-ai-train-yaml` will store the YAML file into `.states`
folder for training AI.

The `--dump-ai-train-yaml` will only store YAML files with top level
description and the output will only contains the difference between
desired state and current state.

Signed-off-by: Gris Ge <fge@redhat.com>
2024-05-31 11:26:27 +08:00
Gris Ge
560118251a test: Isolate ipsec test environment setup code out
Moved the ipsec test environment setup code to `testlib/ipsec.py` which
provides python class `IpsecTestEnv` with context supported.

Since the `rsa_signatures` is generated at runtime, you can only access
it via `IpsecTestEnv().rsa_signatures` now.

Example code on using it

```python
with IpsecTestEnv() as env:
    print(env.rsa_signatures)
```

Signed-off-by: Gris Ge <fge@redhat.com>
2024-05-28 17:26:41 +08:00
Íñigo Huguet
193cf8e4c5 test: integration: routes: fix wrong default table_id comparison
Nmstate uses the value '0' to indicate the default table ID, but the
kernel uses 254. Because of that, in assert_routes we must modify one of
the routes to compare them.

However, what we were doing was: if the desired route has table_id ==
default, then set the kernel route's table_id to default. This is wrong
because a desired route with table_id==default mustn't match with a
kernel route with table_id=123, for example.

Fix it by normalizing all routes to be compared to use the kernel's
default if and only if they were set to use the default table_id.

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2024-04-09 17:48:14 +08:00
Íñigo Huguet
615bf12e6d test: route: add integration test for cwnd attribute
New helper function assert_routes_missing, refactoring testlib/route.py
at the same time to avoid duplications.

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2024-03-20 19:08:19 +08:00
Fernando Fernandez Mancera
2657650c1a Revert "brdige/bond: Add support of slaves back as deprecated"
This reverts commit 631ff65558774c5bbf8aed83fcf201a2f2d9935b.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2024-02-20 11:38:51 +01:00
Gris Ge
59348aa50d test: Remove test interface before create
The `nmcli c delete dummy1` in previous tests does not guarantee
the interface been deleted upon the command return, hence we might
got interface exist error if we do `ip link add dummy1 type dummy`
in `test_convert_unmanged_interface_to_managed`.

To fix it, just delete the test interface before create it.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-11-30 16:25:32 +08:00
Wen Liang
f8c57a88fe route: Add support for the route-type
When users have BGP routing setups, it is common practice to blackhole
some less-specific routes in order to avoid routing loops, and the BGP
router might insert a more specific route dynamically afterwards.

Examples:

```
interfaces:
  - name: eth1
    type: ethernet
    state: up
    ipv4:
      address:
        - ip: 192.0.2.251
          prefix-length: 24
      dhcp: false
      enabled: true

routes:
  config:
    - destination: 198.51.100.0/24
      metric: 150
      next-hop-address: 192.0.2.1
      next-hop-interface: eth1
      table-id: 254
    - destination: 198.51.200.0/24
      route-type: blackhole
```

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2023-11-24 09:30:05 +08:00
Gris Ge
631ff65558 brdige/bond: Add support of slaves back as deprecated
With enough user complains, we would like to adding old property `slaves` back
to bond, linux bridge and ovs bridge as alias of `port`/`ports`.

A warning message will be emitted when this deprecated property been
used in YAML/JSON desire state.

Considering we never expose this property via Rust API, hence no need to
mark this internal property as deprecated in Rust API.

Unit and integration test case included.

Manually confirmed warning message will show when used, it is waste of
time to write test case to assert warning message in this case.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-11-15 13:36:56 +08:00
Gris Ge
6f629d53bc test: Remove verify_change=False for absent action
For test `test_create_ovs_with_internal_ports_in_reverse_order` which
check absent of interface right after the `state: absent` applied,
if we use `verify_change=False`, nmstate will not wait till interface
gone.

This patch removed all `verify_change=False` for absent action.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-10-01 00:04:50 +08:00
Gris Ge
261adfd722 test: Move eth1 and eth2 setup to pytest fixture
Previously we were using run-tests.sh to setup the eth1 and eth2,
after moving this into pytest fixture, the `pytest` could works out of
box.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-09-30 01:09:51 +08:00
Gris Ge
b42197aead route rule: Support suppress-prefix-length
Adding support of ip route rule `suppress-prefix-length` which equal to
`suppress_prefixlength` option in `ip route` command.

Example:

```
route-rules:
  config:
    - ip-from: 192.168.3.2/32
      suppress-prefix-length: 0
      route-table: 200
    - ip-from: 2001:db8:b::/64
      suppress-prefix-length: 1
      route-table: 200
```

Integration test cases included.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-07-26 16:05:03 +08:00
Gris Ge
769fe9115e ovs: New allow-extra-patch-ports option
Introducing `allow-extra-patch-ports` to OVS bridge section which will
allows extra OVS patch port found when applying or verifying. For
example:

```yml
- name: br0
  type: ovs-bridge
  state: up
  bridge:
    allow-extra-patch-ports: true
    port:
    - name: eth1
```

This YAML will not remove existing patch port of `br0` when applying,
and also ignore extra OVS patch found during verification.

This property will not be persisted, every time you modify
ports of specified OVS bridge, you need to explicitly define this
property if not using default value.

Unit test cases and integration test case included.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-07-20 19:54:23 +08:00
Gris Ge
2b76661971 nm: Preserve gateway when not desired
Nmstate is using `routes` instead of `gateway` for storing gateway.
When a NM connection has IP config change without route changes, the
gateway stored in `gateway` property will lose.

To fix that, we do not reset `gateway` property unless IP been disabled
or has route changes.

Integration test case included.

Reference: https://bugzilla.redhat.com/show_bug.cgi?id=2212741

Signed-off-by: Gris Ge <fge@redhat.com>
2023-07-18 10:31:13 +08:00
Gris Ge
59148e75db test: add test for bond port revive
Add test case to simulate the import use case in
https://bugzilla.redhat.com/show_bug.cgi?id=2207690

The IP on VLAN of bond should be assigned back when bond port link
revived.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-07-03 10:48:00 +02:00
Gris Ge
23be5826d4 test: Fix random failure of test_new_bond_uses_mac_of_first_port_by_name
The `test_new_bond_uses_mac_of_first_port_by_name` has random failure
with 1% rate, it is caused by nmstate not properly clean up in previous
test as it is instructed to delete interface with `verify=False` which
cause nmstate return when interface might be still deleting by
NetworkManager.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-05-22 18:41:47 +02:00
Gris Ge
bd814026b2 CI: Fix random failure on test_ignore_interface_mentioned_in_port_list
In https://github.com/nmstate/nmstate/actions/runs/5000804973/jobs/8958880385
we noticed the `setup of test_ignore_interface_mentioned_in_port_list`
will fail as `ip link add brtest0 type bridge` return 2 indicating a
bridge with the same name exists.

This is because in previous test, the clean up is using
`verify_change=False` which does not grantee the linux bridge is removed
by absent action.

To fix that, we remove `verify_change=False` and the clean up of
`linux_bridge()` should make sure the bridge is removed.

The `ip link del` command does not guarantee on link been removed on
exit, hence we use nmstate to replace all `ip link del` command in
tests.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-05-18 08:49:16 +02:00
Gris Ge
fb3b453ff3 test: Remove leftover of test_add_qinq_vlan
The test case `test_add_qinq_vlan` forgot to remove the interface on
finish.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-04-20 11:52:54 +02:00
Gris Ge
334fcf2e81 ip: Support static IP address on with auto ip stack
Introducing two properties for IP address:
 * `valid-left`: seconds for IP address been valid. `forever` means
   static.
 * `preferred_left`: seconds for IP address been preferred. `forever`
   means static.

With above properties, we can identify which certain IP address is
retrieved from DHCP/Autoconf so we don't convert dynamic IP address to
static when user apply the queried state back.

With this patch, user is allowed to set static IP address with
`dhcp: true` and/or `autoconf: true`.

When desire state has DHCP/Autoconf disabled but all desired IP
addresses are dynamic, nmstate will convert those dynamic IP to static.
This is common use case where user just copy retrieved dynamic IP and
hoping nmstate can convert it to static.

Integration test cases included.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-04-10 17:12:45 +08:00
Gris Ge
dbb3426c55 test: Add test case for preserving IP order of external managed interface
Add test case ensuring we preserve the IP address order when consuming a
external managed interface.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-03-28 16:59:34 +08:00
Gris Ge
c590327469 test: Fix test_wait_sriov_vf_been_created on mlx5 NIC
On some `mlx5_core` NIC, the `ip -d link show <pf_name>` does not have
VF interface name, which will fail the `test_wait_sriov_vf_been_created`
for VF name not found.

The fix would be changed the test code to use this folder for VF
interface name as the production code:

    /sys/class/net/{pf_name}/device/virtfn{sriov_id}/net/

Manually test on mlx5 MT27710 NIC.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-03-21 12:23:30 +08:00
Esa Varemo
5a0ca40742 vxlan: Add VXLAN properties for EVPN use
In order to be able to use VXLAN interfaces as part of an
EVPN fabric (separate control plane for VTEP and MAC learning),
some expansions are done to the configurable properties:

- Make base-if non-mandatory

  EVPN networks are often run on top of a L3 underlay, which
  means that there are several L3 links to the host where
  ECMP routing is desired. The VXLAN interface should not be
  tied to any physical interface (and it's not required since
  multicast is not used) and the egress interface is determined
  through standard routing.

- Allow specifying local IP

  Since the VXLAN interface is not tied to any physical interface,
  it is often desired to source the tunnel from a loopback IP.

- Disable data plane MAC learning

  In EVPN MAC learning is handled through a separate control
  plane like MP-BGP (e.g. FRR as daemon) writing entries to the
  bridge FDB.

Unit test cases and integration test case included.

Signed-off-by: Esa Varemo <git@esav.fi>
2023-03-08 15:20:55 +08:00
Gris Ge
8f6801800d sriov: Fix SR-IOV enabling and use in single desire state
Currently, we isolate SR-IOV PF changes out for `enable-and-use` use
case, but the second desire state contains no SR-IOV PF changes which
cause the verification stage does not wait on VF shows up again.

Instead of isolating PF changes out to apply first, we only clone PF
changes to apply first when VF count changed and has missing ethernet in
desire state. This means we will apply twice SR-IOV PF changes to ensure
the final apply also wait on VF shows up.

Unit test cases included.

Current integration test case `test_wait_sriov_vf_been_created` and
`test_enable_sriov_and_use_future_vf` have covered the use case.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-02-15 15:57:36 +08:00
Gris Ge
8ec213b8cb ovs: Support interface level other_config (api break)
The Rust API changed:

    The `OvsBridgeBondConfig.other_config: Option<HashMap>` changed to
    `OvsBridgeBondConfig.ovs_db:  Option<OvsDbIfaceConfig>`

The YAML API changed:

    The `other_config` under ovs bond should be stored under `ovs-db`
    section, please check follow up example for detail.

Considering the interface level `other_config` never works in previous
release, this is API change is acceptable.

Example on `other_config` of OVS bridge:

```yml
interfaces:
- name: br0
  type: ovs-bridge
  state: up
  ovs-db:
    other_config:
      in-band-queue: '12'
  bridge:
    port:
    - name: eth1
    - name: ovs0
```

Example on `other_config` of OVS Bond:

```yml
- name: br0
  type: ovs-bridge
  state: up
  bridge:
    port:
    - name: bond1
      link-aggregation:
        mode: balance-slb
        ovs-db:
          other_config:
            bond-miimon-interval: "100"
        port:
          - name: eth2
          - name: eth1
```

Example on `other_config` of OVS interface:

```yml
- name: eth1
  type: ethernet
  state: up
  ovs-db:
    other_config:
      emc-insert-inv-prob: 90
```

We hide interface level `ovs-db` section if it is empty. This help us
supporting older NetworkManager where `other_config` is not supported
yet. User will get error when they apply above yaml on old
NetworkManager:

    NmstateError: DependencyError: Please upgrade NetworkManager for
    specified interface type: Connection(InvalidSetting):ovs-other-config:
    unknown setting name

Integration test case included.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-01-18 09:40:39 +01:00
Gris Ge
ae3f45a725 ovsdb: Fix verification error when ovs daemon off
When applying `ovs-db: {}` with ovs daemon stopped, nmstate will fail
with:

    NmstateError: VerificationError: Verification failure:
    ovsdb.external_ids desire '{}', current 'null'

Fixed by treating `ovs-db: {}` as

```yml
ovs-db:
  external_ids: {}
  other_config: {}
```

Unit test case and integration test case included.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-01-10 18:02:17 +01:00
Gris Ge
f619d8b486 nm dns: Fix error when moving dns from port to controller
When moving IP and DNS config from port to controller, nmstate will fail
with verification error as nmstate failed to store DNS config to
controller.

Fixed by:
 * `apply_ctrller_change()` should purge IP stack if interface is not
   valid to IP any more in merge state.

 * `store_dns_config()` should reconfig the DNS if changed interface is
   DNS interface and not valid for current DNS anymore even DNS config
   not changed.

 * `purge_dns_config()` should do nothing for absent interface.

Integration test case crated for two use cases:
 * Move identical IP and DNS config from port to controller.
 * Move identical IP from port to controller but with DNS changed.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-01-06 19:54:41 +08:00
Gris Ge
249961df2a test: Speed up test_state_absent_can_remove_down_profiles
The`test_state_absent_can_remove_down_profiles` takes 90 seconds to
finish as the `assertlib.assert_state_match()` will keep retrying till
matches or expired.

Fixed by add `no_retry` option to `assertlib.assert_state_match()`

Signed-off-by: Gris Ge <fge@redhat.com>
2022-12-24 21:21:13 +01:00
Gris Ge
097553bea7 test: Speed up the test_ipv6_dhcp_switch_on_to_off
The `test_ipv6_dhcp_switch_on_to_off` and other similar test cases
use `assert not _poll()` which only returns after `DEFAULT_TIMEOUT`
(20 seconds) expires.

Fix it by introduce `_poll_till_not()` for waiting on false instead of
true.

Signed-off-by: Gris Ge <fge@redhat.com>
2022-12-18 21:48:52 +08:00
Gris Ge
81c661c2f7 route rule: Add support of iif and action.
* Added `RouteRule.iif` for matching on incoming interface name.
* Added `RouteRule.action` for these actions:
    * `RouteRuleAction::Blackhole`
    * `RouteRuleAction::Unreachable`
    * `RouteRuleAction::Prohibit`

Bumped required of nispor to 1.2.9 for the fix of route rule actions.

Integration test cases included.

Signed-off-by: Gris Ge <fge@redhat.com>
2022-12-13 21:43:38 +08:00
Gris Ge
638704ff13 test: Retry on assert_absent()
There is a race when we delete OVS interface via NM and querying OVS
interface right after it. NM might still how this OVS interface in its
cache.

Instead of instant fail, we retry in `assert_absent()`.

Signed-off-by: Gris Ge <fge@redhat.com>
2022-12-09 10:57:11 +08:00
Fernando Fernandez Mancera
7ddd51853d tests, ovs: add updelay and downdelay ovs-bond options test
Add missing integration tests for OVS Link Aggregation support. We
support downdelay and updelay so they need to be tested properly.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2022-11-24 12:59:14 +01:00
Gris Ge
badcee4c8c Introduce support of nmpolicy
Introducing support of nmpolicy syntax[1] including rust, python and C
bindings.

Implementation workflow:
 * `NetworkPolicy` could deserialize from existing nmpolicy file.
 * Each of capture line will produce a new `NetworkState` and stored for
   follow up capture line processing.
 * Each capture line will be converted to `Vec<NetworkCaptureToken>`,
   then fill into `NetworkCaptureCommand` for filtering or updating
   matched `NetworkState`.
 * We use `serde_json::Map` to walk through the property defined in the
   format of `routes.running.next-hop-interface`.

The cli tools could be used also:

    nmstatectl p <policy.yml> [-c current_state.yml] \
        [-s saved_capture.yml] [-o /path/to/output_capture.yml]

API:

 * Using running current to generate `NetworkState`:

   ```rust
   let policy: NetworkPolicy = serde_yaml::from_str(policy_content)?;
   let state = NetworkState::try_from(policy)?
   ```

 * Use saved current to generate `NetworkState`:

   ```rust
   let mut policy: NetworkPolicy = serde_yaml::from_str(policy_content)?;
   policy.current = Some(serde_yaml::from_str(current_state_content)?);
   let state = NetworkState::try_from(policy)?
   ```

 * Store captured data:

   ```rust
   let policy: NetworkPolicy = serde_yaml::from_str(policy_content)?;
   let current_state = serde_yaml::from_str(current_state_content)?;
   let captured_states = policy.capture.execute(&current_state)?;
   // Use your own way to store the captured data
   // You may also use `NetworkCaptureRules::execute()` directly.
   ```

 * Load captured data:

   ```rust
   // Use your own way to load the data. We just need
   // HashMap<String, NetworkState> for captured_states
   let current_state = serde_yaml::from_str(current_state_content)?;
   let policy: NetworkPolicy = serde_yaml::from_str(policy_content)?;
   let state = policy.desired.fill_with_captured_data(&captured_states)?;
   // You may also use `NetworkStateTemplate::fill_with_captured_data()`
   // directly.
   ```

Both unit test cases and integration test case are included.

[1]: https://nmstate.io/nmpolicy/user-guide/102-policy-syntax.html

Signed-off-by: Gris Ge <fge@redhat.com>
2022-11-15 15:56:11 +08:00
Fernando Fernandez Mancera
c53dc56824 route_rule: support from all to all routing policy
Add support to `from all to all` routing policy. In static config
generator it will add `from 0.0.0.0/0` or `from ::/0` to the keyfile.

A new parameter `family` have been introduced to the route-rule config
field. This parameter is used to specify the address family. If `family`
is not specified it will fail on validation, if not specified from
Nispor it will assume IPv4 as it was done in the past.

Example:

```yaml
route-rules:
  config:
    - route-table: 254
      priority: 100
      family: ipv4
```

Integration test cases added.

Fixes #1417

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2022-11-10 13:59:40 +01:00
Gris Ge
e69f036d1e test: Add test case for IP address order
Add test case to test the order of IP addresses is preserved.

It is known issue in RHEL 8 with reverted IPv6 address order. Downstream
nmstate package will have their own patch to revert the address list
before sent to NM.

Signed-off-by: Gris Ge <fge@redhat.com>
2022-11-07 14:04:22 +01:00
Fernando Fernandez Mancera
95f1c19351 rule: add support to fwmark and fwmask
Introduce support to fwmark and fwmask properties for routing policy
configuration. Please, consider the following example:

```yaml
route-rules:
  config:
    - ip-to: 192.0.2.3/24
      ip-from: 198.51.100.0/24
      priority: 100
      route-table: 254
      fwmark: 0x30
      fwmask: 0x10
```

Integration test added.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2022-10-24 19:13:04 +08:00
Gris Ge
13cec24117 SRIOV: Support referring interface using PF name and VF ID
Kernel function `dev_valid_name()` indicate `:` is not allowed character
for interface name. Hence we introduce special interface name format
when referring a SRIOV VF interface without knowing its real interface
name.

    sriov:<pf_name>:<vf_id>

You may use this SRIOV VF naming schema for:
 * Top interface name
 * Bond port name
 * Linux bridge port name
 * OVS bridge port name
 * OVS bond port name

Both Unit test cases and integration test cases are included.
Integration test cases are tested on Mellanox MT27710(mlx5).

Signed-off-by: Gris Ge <fge@redhat.com>
2022-09-30 10:44:03 +02:00
Gris Ge
64df47df95 test: Manually activate all connections after gen_conf
After NM reload the gen_conf configurations, we manually activate all
the NM connections.

Signed-off-by: Gris Ge <fge@redhat.com>
2022-09-27 17:34:14 +02:00
Gris Ge
f6e5cd4d75 test: Extent timeout in assert_state_match
In the genconf test, we should wait extra time after `nmcli c reload`.
Extending to timeout of `assert_state_match` to 50 seconds.

Signed-off-by: Gris Ge <fge@redhat.com>
2022-09-27 17:34:14 +02:00
Gris Ge
e94a54fa76 veth: Show veth interface as type: veth
Previously, in order to simplify the code workflow, we are showing both
veth and normal ethernet as `type: ethernet`. This has break kubernetes
use case where they need it to identify the veth interfaces.

Changed to show veth interface as `type: veth`. When its peer is in
another network namespace, hide the `veth` section.

Expand the integration test cases to cover these use cases:

 * `test_eth_with_veth_conf`
   Desire state is desiring ethernet interface with veth configuration.
   Raise InvalidArgument error (NmstateValueError exception in python)

 * `test_add_veth_with_ethernet_peer`
   Desire state contains both veth and veth peer interface. But veth
   peer interface is set as `type: ethernet`.

 * `test_add_veth_with_veth_peer_in_desire`
   Desire state contains both veth and veth peer interface. Both veth
   and peer interfaces are set as `type: veth` with `veth` configure
   pointing to each other.

 * `test_modify_veth_peer`
   Change veth peer. The old peer should be removed.

 * `test_veth_without_peer_fails`
   When adding new veth(not exist) without veth peer defined in veth
   configure, raise InvalidArgument error (NmstateValueError exception
   in python).

 * `test_change_veth_with_veth_type_without_veth_conf`
   With pre-exist veth, changing other configure with `type: veth` and
   no veth configure.

 * `test_change_veth_with_eth_type_without_veth_conf`
   With pre-exist veth, changing other configure with `type: ethernet` and
   no veth configure.

 * `test_veth_with_ignored_peer`
   With pre-exist veth and its peer marked as ignored (unmanaged by NM).
   Applying desire state with `type: veth` and veth configuration should
   not fail. And the veth configuration should be ignored.

 * `test_veth_with_ignored_peer_changed_to_new_peer`
   With pre-exist veth and its peer marked as ignored (unmanaged by NM).
   Nmstate will raise InvalidArgument error (NmstateValueError exception
   in python) when user try to change its peer. Also have unit test case
   for this.

Signed-off-by: Gris Ge <fge@redhat.com>
2022-09-13 10:28:27 +02:00