Bug 1482772

Summary: Cannot specify multiple ip addresses with nmcli con add
Product: Red Hat Enterprise Linux 7 Reporter: Venkatesh Kavtikwar <vkavtikw>
Component: NetworkManagerAssignee: Beniamino Galvani <bgalvani>
Status: CLOSED ERRATA QA Contact: Desktop QE <desktop-qa-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.3CC: atragler, bgalvani, fgiudici, lrintel, rkhan, sukulkar, thaller, vbenes, vkavtikw
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 13:29:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Venkatesh Kavtikwar 2017-08-18 05:29:33 UTC
Description of problem:

Cannot specify multiple ip addresses with nmcli con add in RHE 7.3 (Documentation update)


Version-Release number of selected component (if applicable):

NetworkManager-1.4.0-12.el7 and later


How reproducible:

Cu was using below command to add multiple IP's at the time of creating a new connection in order NetworkManager version like NetworkManager-1.0.4.-9.el7

/bin/nmcli con add type team autoconnect false con-name team0 ifname team0 config '{"device":"team0","runner":{ "fast_rate":true,"name":"lacp" }}' ip4 10.64.32.98/24 ip4 10.64.32.56/24 gw4 10.64.32.1

Where CU was Using "ip4" parameter to add multiple IP's and was working.

While modifying the connection they were using ipv4.address or +ipv4.address to  modify or add new IP.

In later upgrades from NetworkManager-1.4.0-12.el7 and ahead, I think as a part of improvement and to match parameters, we have started to use both ip4 & ipv4.address to add IP address while creating a new connection but this fails when we add multiple IP's for new connection.

Below commands will assign only one IP (mentioned in last) instead of multiple.

========================

/bin/nmcli con add type team autoconnect false con-name team0 ifname team0 config '{"device":"team0","runner":{ "fast_rate":true,"name":"lacp" }}' ip4 10.64.32.98/24 ip4 10.64.32.56/24 gw4 10.64.32.1

/bin/nmcli con add type team autoconnect false con-name team0 ifname team0 config '{"device":"team0","runner":{ "fast_rate":true,"name":"lacp" }}' ipv4.address 10.64.32.98/24 ipv4.address 10.64.32.56/24 gw4 10.64.32.1

========================

We have a solution for this, that we need to either of the syntax to add multiple IP's in latest versions of NetworkManager


========== O/P from my local system ==============


# nmcli connection add type ethernet con-name ens9 ifname ens9 ipv4.addresses "10.0.0.8/24, 10.0.0.9/24"

# nmcli connection add type ethernet con-name ens9 ifname ens9 ipv4.method manual ipv4.addresses 10.0.0.1/24 +ipv4.address 10.0.0.2/24

==================================================


The main concern here is that, in "man nmcli" we have mentioned below things, which incorrectly says that we can use "ipv4.address" multiple times (without providing +) to add multiple IP's while creating new connection.


The man page states:
       Table 22. IPv4 options
       ┌──────┬────────────────┬──────────────────────────────────┐
       │Alias │ Property       │ Note                             │
       ├──────┼────────────────┼──────────────────────────────────┤
       │ip4   │ ipv4.addresses │ This option can be specified     │
       │      │                │ multiple times.  It's equivalent │
       │      │                │ of using +ipv4.addresses syntax. │
       ├──────┼────────────────┼──────────────────────────────────┤
       │gw4   │ ipv4.gateway   │                                  │
       └──────┴────────────────┴─────────────────────────────────┘

It says ipv4.address is equivalent to "+ipv4.address" and that's where CU has raised the concern.

So with we need to correct the documentation in order to match with current settings we have with nmcli or we have to make changes to nmcli code to add multiple IP address using below queries


========================

/bin/nmcli con add type team autoconnect false con-name team0 ifname team0 config '{"device":"team0","runner":{ "fast_rate":true,"name":"lacp" }}' ip4 10.64.32.98/24 ip4 10.64.32.56/24 gw4 10.64.32.1

/bin/nmcli con add type team autoconnect false con-name team0 ifname team0 config '{"device":"team0","runner":{ "fast_rate":true,"name":"lacp" }}' ipv4.address 10.64.32.98/24 ipv4.address 10.64.32.56/24 gw4 10.64.32.1

========================


Please let us know further on this.

Comment 2 Beniamino Galvani 2017-08-30 12:36:09 UTC
This:

  nmcli con add type team ... ip4 10.64.32.98/24 ip4 10.64.32.56/24

is correct because 'ip4' is an alias for '+ipv4.address'. This syntax
didn't work on RHEL 7.3 but does work on RHEL 7.4.

On the other hand, this:

  nmcli con add type team ... ipv4.address 10.64.32.98/24 ipv4.address 10.64.32.56/24

is not intended to work as you expect because if you specify a
property multiple times only the last occurrence is considered. In the
man page snippet you mentioned, "It's equivalent of using
+ipv4.addresses syntax" refers to the "ip4" alias only.

For these reason, I propose to close this bug as CURRENTRELEASE.

Venkatesh, what do you think?

Comment 3 Venkatesh Kavtikwar 2017-09-11 16:41:45 UTC
Hello,

Thanks for your inputs.

Glad that it's been introduced back again in RHEL 7.4 and the same can be updated to CU. 


The only thing which is misleading here is "This" in the notes part. Can we change it to "ip4" instead so as to eliminate confusion? Please share your thoughts.



       Table 22. IPv4 options
       ┌──────┬─────────────────────────────────────────┬────────────────────────────┐
       │Alias │ Property                                │ Note                       │
       ├──────┼─────────────────────────────────────────┼────────────────────────────┤
       │ip4   │ ipv4.addresses                          │ This option can be         │
       │      │                             ipv4.method │ specified multiple times.  │
       │      │                                         │ It's equivalent of using   │
       │      │                                         │ +ipv4.addresses syntax and │
       │      │                                         │ setting ipv4.method to     │
       │      │                                         │ manual.                    │
       ├──────┼─────────────────────────────────────────┼────────────────────────────┤
       │gw4   │ ipv4.gateway                            │                            │
       └──────┴─────────────────────

────────────────────┴────────────────────────────┘

Comment 4 Beniamino Galvani 2017-09-13 12:24:14 UTC
How about the following?

┌─────┬──────────────┬──────────────────────────────────────────────────────────┐
│Alias│Property      │ Note                                                     │
├─────┼──────────────┼──────────────────────────────────────────────────────────┤
│ip4  │ipv4.addresses│ The alias is equivalent to the +ipv4.addresses syntax and│
│     │ipv4.method   │ also sets ipv4.method to manual. It can be specified     │
│     │              │ multiple times.                                          │
├─────┼──────────────┼──────────────────────────────────────────────────────────┤
│gw4  │ipv4.gateway  │                                                          │
└─────┴──────────────┴──────────────────────────────────────────────────────────┘

Table 24. IPv6 options
┌─────┬──────────────┬──────────────────────────────────────────────────────────┐
│Alias│Property      │ Note                                                     │
├─────┼──────────────┼──────────────────────────────────────────────────────────┤
│ip6  │ipv6.addresses│ The alias is equivalent to the +ipv6.addresses syntax and│
│     │ipv6.method   │ also sets ipv6.method to manual. It can be specified     │
│     │              │ multiple times.                                          │
├─────┼──────────────┼──────────────────────────────────────────────────────────┤
│gw6  │ipv6.gateway  │                                                          │
└─────┴──────────────┴──────────────────────────────────────────────────────────┘

I think we should also add a test to our CI to check that the syntax keeps working in future NM versions:

    @ipv4
    @ipv4_multiple_ip4
    @ver+=1.4.2
    Scenario: nmcli - ipv4 - method - static using multiple "ip4" options
    * Add a new connection of type "ethernet" and options "ifname eth1 con-name ethie ip4 192.168.124.1/24 ip4 192.168.125.1/24"
    * Bring "up" connection "ethie"
    Then "192.168.124.1/24" is visible with command "ip a s eth1"
    Then "192.168.125.1/24" is visible with command "ip a s eth1"


After the documentation fix is merged, I'll move this bug to MODIFIED so that QE will add the test to CI.

Comment 5 Venkatesh Kavtikwar 2017-09-13 13:55:51 UTC
Hello,

Thanks for the reply.

Yes, this is more clear now. Thanks. 

Please let us know further, meanwhile, I will provide an update to the CU.

Comment 8 Vladimir Benes 2018-01-31 15:05:26 UTC
working well in CI

Comment 11 errata-xmlrpc 2018-04-10 13:29:44 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:0778