DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Alex Kiselev <alex@therouter.net>, "dev@dpdk.org" <dev@dpdk.org>,
	Chas Williams <3chas3@gmail.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [dpdk-dev] [PATCH v3] net/bonding: add add/remove mac addrs
Date: Tue, 19 Jun 2018 10:13:19 +0000	[thread overview]
Message-ID: <VI1PR0501MB2608B737B5CB2871BD2E5C01D2700@VI1PR0501MB2608.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <162811227.20180619121942@therouter.net>



 From: Alex Kiselev
> Hi Matan.
> 
> > Hi Alex
> 
> > Please see comments below.
> 
> 
> >> +
> >> +             ret = rte_eth_dev_mac_addr_add(slave_port_id, mac_addr, 0);
> >> +             if (ret < 0) {
> >> +                     /* rollback */
> >> +                     for (i--; i > 0; i--)
> >> +
> 
> > In case of failure in the first mac address(i=1) you are going to
> > remove the default mac address(i=0) from the slave.
> In that case i will be incremented first and will be equal to 0, then for condition
> will fail and the loop body will not be executed.
> 

Yes, my mistake.

> 
> >>       rte_eth_dev_mac_addr_remove(slave_port_id,
> >> +                                     &bonded_eth_dev->data-
> >> >mac_addrs[i]);
> >> +                     return ret;
> >> +             }
> >> +     }
> >> +
> >> +     return 0;
> >> +}
> >> +
> >> +/*
> >> + * Remove additional MAC addresses from the slave  */ int
> >> +slave_remove_mac_addresses(struct rte_eth_dev *bonded_eth_dev,
> >> +             uint16_t slave_port_id) {
> >> +     int i, ret = 0;
> >> +     struct ether_addr *mac_addr;
> >> +
> >> +     for (i = 1; i < BOND_MAX_MAC_ADDRS; i++) {
> >> +             mac_addr = &bonded_eth_dev->data->mac_addrs[i];
> >> +             if (is_same_ether_addr(mac_addr, &null_mac_addr))
> >> +                     break;
> >> +
> >> +             ret = rte_eth_dev_mac_addr_remove(slave_port_id,
> >> mac_addr);
> >> +     }
> 
> > I suggest to return the first error, also in case of all success with
> > last failure, the code here wrongly returns success.
> Yeah, you are right. I'll fix it.
> 
> >> +
> >> +     for (i = 0; i < internals->slave_count; i++) {
> >> +             ret = rte_eth_dev_mac_addr_add(internals->slaves[i].port_id,
> >> +                             mac_addr, vmdq);
> >> +             if (ret < 0) {
> >> +                     /* rollback */
> >> +                     for (i--; i >= 0; i--)
> 
> > In case of failure in the first slave(i=0) you are going probably to get memory
> error (i=-1).
> The same logic apply here. When i ==-1 the condition will fail and the loop body
> will not be executed;

Yes, my mistake.

> 
> 
> 
> 
> --
> Alex

  reply	other threads:[~2018-06-19 10:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0d1c4f28-e08b-40e7-9b9e-0d4bdd15279a@VE1EUR03FT041.eop-EUR03.prod.protection.outlook.com>
2018-06-19  9:00 ` Matan Azrad
2018-06-19  9:19   ` Alex Kiselev
2018-06-19 10:13     ` Matan Azrad [this message]
2018-06-20  8:42   ` Alex Kiselev
2018-06-19  8:32 Alex Kiselev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR0501MB2608B737B5CB2871BD2E5C01D2700@VI1PR0501MB2608.eurprd05.prod.outlook.com \
    --to=matan@mellanox.com \
    --cc=3chas3@gmail.com \
    --cc=alex@therouter.net \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).