>> 4) sw_interface_dump return loop10's info instead of loop1

> predictable behavior

Probably it would be sufficient to just
improve the current [1] documentation.

Vratko.

[1] 
https://github.com/FDio/vpp/blob/f49ba0e81e0cb9b9f8075cb4ce051b5bacde8ad3/src/vnet/interface.api#L206

From: vpp-dev@lists.fd.io <vpp-dev@lists.fd.io> On Behalf Of Dave Barach via 
Lists.Fd.Io
Sent: Thursday, 2019-March-14 13:55
To: "Zhou You(Joe Zhou) <zhouyo...@qq.com>; Paul Vinciguerra 
<pvi...@vinciconsulting.com>; vpp-dev@lists.fd.io
Cc: vpp-dev@lists.fd.io
Subject: Re: Re: [vpp-dev] is sw_interface_dump api bug?

Personally, I’m a fan of asking for all the interface names - as infrequently 
as possible - and building whatever data structure you like in client code to 
do your favorite kind of wildcard lookup.

To avoid unintended consequences for control-plane codes we don’t even know 
about, please don’t change the name filter code in vpp. It’s a really simple 
prefix check, with predictable behavior...

Thanks... Dave


FWIW:

int
api_sw_interface_dump (vat_main_t * vam)
{
  vl_api_sw_interface_dump_t *mp;
  vl_api_control_ping_t *mp_ping;
  hash_pair_t *p;
  name_sort_t *nses = 0, *ns;
  sw_interface_subif_t *sub = NULL;
  int ret;

  /* Toss the old name table */
  /* *INDENT-OFF* */
 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
  ({
    vec_add2 (nses, ns, 1);
    ns->name = (u8 *)(p->key);
    ns->value = (u32) p->value[0];
  }));
  /* *INDENT-ON* */

  hash_free (vam->sw_if_index_by_interface_name);

  vec_foreach (ns, nses) vec_free (ns->name);

  vec_free (nses);

  vec_foreach (sub, vam->sw_if_subif_table)
  {
    vec_free (sub->interface_name);
  }
  vec_free (vam->sw_if_subif_table);

  /* recreate the interface name hash table */
  vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));

  /*
   * Ask for all interface names. Otherwise, the epic catalog of
   * name filters becomes ridiculously long, and vat ends up needing
   * to be taught about new interface types.
   */
  M (SW_INTERFACE_DUMP, mp);
  S (mp);

  /* Use a control ping for synchronization */
  MPING (CONTROL_PING, mp_ping);
  S (mp_ping);

  W (ret);
  return ret;
}

/*
* Special-case: build the interface table, maintain
* the next loopback sw_if_index vbl.
*/
static void vl_api_sw_interface_details_t_handler
  (vl_api_sw_interface_details_t * mp)
{
  vat_main_t *vam = &vat_main;
  u8 *s = format (0, "%s%c", mp->interface_name, 0);

  hash_set_mem (vam->sw_if_index_by_interface_name, s,
           ntohl (mp->sw_if_index));

  /* In sub interface case, fill the sub interface table entry */
  if (mp->sw_if_index != mp->sup_sw_if_index)
    {
      sw_interface_subif_t *sub = NULL;

      vec_add2 (vam->sw_if_subif_table, sub, 1);

      vec_validate (sub->interface_name, strlen ((char *) s) + 1);
      strncpy ((char *) sub->interface_name, (char *) s,
             vec_len (sub->interface_name));
     sub->sw_if_index = ntohl (mp->sw_if_index);
      sub->sub_id = ntohl (mp->sub_id);

      sub->sub_dot1ad = mp->sub_dot1ad;
      sub->sub_number_of_tags = mp->sub_number_of_tags;
      sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
      sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
      sub->sub_exact_match = mp->sub_exact_match;
      sub->sub_default = mp->sub_default;
      sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
      sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;

      /* vlan tag rewrite */
      sub->vtr_op = ntohl (mp->vtr_op);
      sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
      sub->vtr_tag1 = ntohl (mp->vtr_tag1);
      sub->vtr_tag2 = ntohl (mp->vtr_tag2);
    }
}

From: vpp-dev@lists.fd.io<mailto:vpp-dev@lists.fd.io> 
<vpp-dev@lists.fd.io<mailto:vpp-dev@lists.fd.io>> On Behalf Of "Zhou You(Joe 
Zhou)
Sent: Thursday, March 14, 2019 7:01 AM
To: Paul Vinciguerra 
<pvi...@vinciconsulting.com<mailto:pvi...@vinciconsulting.com>>; 
vpp-dev@lists.fd.io<mailto:vpp-dev@lists.fd.io>
Subject: Re: [vpp-dev] is sw_interface_dump api bug?

Hey Paul,
  Thanks very much, I got it,  I have a misunderstanding about this API, for 
this api return all the interface's info which include the param of name_filter.
  Maybe it's a False patch. Thank you again:-)

  ---
  Best Regards
  Joe


------------------ 原始邮件 ------------------
发件人: "Paul 
Vinciguerra"<pvi...@vinciconsulting.com<mailto:pvi...@vinciconsulting.com>>;
发送时间: 2019年3月14日(星期四) 晚上6:45
收件人: "vpp-dev"<vpp-dev@lists.fd.io<mailto:vpp-dev@lists.fd.io>>;
主题: Re: [vpp-dev] is sw_interface_dump api bug?

  4) sw_interface_dump return loop10's info instead of loop1

I tested without your patch, and sw_interface_dump returns both interfaces that 
match the filter of 'loop1'.

              Name               Idx    State  MTU (L3/IP4/IP6/MPLS)     
Counter          Count

local0                            0     down          0/0/0/0

loop0                             1     down         9000/0/0/0

loop10                            3     down         9000/0/0/0

loop1                             2     down         9000/0/0/0



dump: ['loop1', 'loop10']

Paul
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#12546): https://lists.fd.io/g/vpp-dev/message/12546
Mute This Topic: https://lists.fd.io/mt/30426855/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-
  • ... "Zhou You(Joe Zhou)
    • ... "Zhou You(Joe Zhou)
    • ... Paul Vinciguerra
      • ... "Zhou You(Joe Zhou)
        • ... Dave Barach via Lists.Fd.Io
          • ... Vratko Polak -X (vrpolak - PANTHEON TECHNOLOGIES at Cisco) via Lists.Fd.Io
            • ... Yohan Pipereau (ypiperea) via Lists.Fd.Io
              • ... Vratko Polak -X (vrpolak - PANTHEON TECHNOLOGIES at Cisco) via Lists.Fd.Io

Reply via email to