summaryrefslogtreecommitdiffstats
path: root/src/plugins/dpdk/device
diff options
context:
space:
mode:
authorSteve Shin <jonshin@cisco.com>2017-07-07 14:57:46 -0700
committerJohn Lo <loj@cisco.com>2017-07-08 14:00:49 +0000
commit042a621b90c9f521b546cbbf724bb908e36f3b25 (patch)
treedf1c777e3e0a7e33e2ce647a2a9b73046cf517df /src/plugins/dpdk/device
parent9a1ae1ac76ca43e799e8281da1177c186e49d4f7 (diff)
lldp packet transmission on a bonded interface
LLDP packets are dropped at interface output node if each slave's link is configured as the LLDP interface. The admin state is configured and managed by the bonded interface, so slave link's state is down by default. The checking for the admin state UP should be ignored for the slave link. Change-Id: I06ca250f42fcb8cc50e0ea3a3817a2c5b56865df Signed-off-by: Steve Shin <jonshin@cisco.com>
Diffstat (limited to 'src/plugins/dpdk/device')
-rwxr-xr-xsrc/plugins/dpdk/device/init.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index 9602e93c54f..17e77618d62 100755
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -1268,9 +1268,9 @@ dpdk_update_link_state (dpdk_device_t * xd, f64 now)
ed->new_link_state = (u8) xd->link.link_status;
}
- if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) &&
- ((xd->link.link_status != 0) ^
- vnet_hw_interface_is_link_up (vnm, xd->hw_if_index)))
+ if ((xd->flags & (DPDK_DEVICE_FLAG_ADMIN_UP | DPDK_DEVICE_FLAG_BOND_SLAVE))
+ && ((xd->link.link_status != 0) ^
+ vnet_hw_interface_is_link_up (vnm, xd->hw_if_index)))
{
hw_flags_chg = 1;
hw_flags |= (xd->link.link_status ? VNET_HW_INTERFACE_FLAG_LINK_UP : 0);
ref='#n201'>201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
/*
 * Copyright (c) 2017 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * bier_disposition : The BIER disposition object
 *
 * A BIER disposition object is present in the IP mcast output list
 * and represents the disposition of a BIER bitmask. After BIER header
 * disposition the packet is forward within the appropriate/specified
 * BIER table
 */

#include <vnet/bier/bier_disp_entry.h>
#include <vnet/bier/bier_hdr_inlines.h>
#include <vnet/fib/fib_path_list.h>
#include <vnet/dpo/drop_dpo.h>

/**
 * The memory pool of all imp objects
 */
bier_disp_entry_t *bier_disp_entry_pool;

/**
 * When constructing the BIER imp ID from an index and BSL, shift
 * the BSL this far
 */
#define BIER_DISP_ENTRY_ID_HLEN_SHIFT 24

static void
bier_disp_entry_lock_i (bier_disp_entry_t *bde)
{
    bde->bde_locks++;
}

void
bier_disp_entry_lock (index_t bdei)
{
    bier_disp_entry_lock_i(bier_disp_entry_get(bdei));
}

static index_t
bier_disp_entry_get_index(bier_disp_entry_t *bde)
{
    return (bde - bier_disp_entry_pool);
}

index_t
bier_disp_entry_add_or_lock (void)
{
    dpo_id_t invalid = DPO_INVALID;
    bier_hdr_proto_id_t pproto;
    bier_disp_entry_t *bde;

    pool_get_aligned(bier_disp_entry_pool, bde, CLIB_CACHE_LINE_BYTES);

    bde->bde_locks = 0;

    FOR_EACH_BIER_HDR_PROTO(pproto)
    {
        bde->bde_fwd[pproto].bde_dpo = invalid;
        bde->bde_fwd[pproto].bde_rpf_id = ~0;
        bde->bde_pl[pproto] = FIB_NODE_INDEX_INVALID;
    }

    bier_disp_entry_lock_i(bde);
    return (bier_disp_entry_get_index(bde));
}

void
bier_disp_entry_unlock (index_t bdei)
{
    bier_disp_entry_t *bde;

    if (INDEX_INVALID == bdei)
    {
        return;
    }

    bde = bier_disp_entry_get(bdei);

    bde->bde_locks--;

    if (0 == bde->bde_locks)
    {
        bier_hdr_proto_id_t pproto;

        FOR_EACH_BIER_HDR_PROTO(pproto)
        {
            dpo_unlock(&bde->bde_fwd[pproto].bde_dpo);
            bde->bde_fwd[pproto].bde_rpf_id = ~0;
            fib_path_list_unlock(bde->bde_pl[pproto]);
        }
        pool_put(bier_disp_entry_pool, bde);
    }
}

typedef struct bier_disp_entry_path_list_walk_ctx_t_
{
    u32 bdew_rpf_id;
} bier_disp_entry_path_list_walk_ctx_t;

static fib_path_list_walk_rc_t
bier_disp_entry_path_list_walk (fib_node_index_t pl_index,
                                fib_node_index_t path_index,
                                void *arg)
{
    bier_disp_entry_path_list_walk_ctx_t *ctx = arg;

    ctx->bdew_rpf_id = fib_path_get_rpf_id(path_index);

    if (~0 != ctx->bdew_rpf_id)
    {
        return (FIB_PATH_LIST_WALK_STOP);
    }
    return (FIB_PATH_LIST_WALK_CONTINUE);
}

static void
bier_disp_entry_restack (bier_disp_entry_t *bde,
                         bier_hdr_proto_id_t pproto)
{
    dpo_id_t via_dpo = DPO_INVALID;
    fib_node_index_t pli;

    pli = bde->bde_pl[pproto];

    if (FIB_NODE_INDEX_INVALID == pli)
    {
        dpo_copy(&via_dpo,
                 drop_dpo_get(bier_hdr_proto_to_dpo(pproto)));
    }
    else
    {
        fib_path_list_contribute_forwarding(pli,
                                            fib_forw_chain_type_from_dpo_proto(
                                                bier_hdr_proto_to_dpo(pproto)),
                                            FIB_PATH_LIST_FWD_FLAG_COLLAPSE,
                                            &via_dpo);

        bier_disp_entry_path_list_walk_ctx_t ctx = {
            .bdew_rpf_id = ~0,
        };

        fib_path_list_walk(pli, bier_disp_entry_path_list_walk, &ctx);
        bde->bde_fwd[pproto].bde_rpf_id = ctx.bdew_rpf_id;
    }

    dpo_stack(DPO_BIER_DISP_ENTRY,
              DPO_PROTO_BIER,
              &bde->bde_fwd[pproto].bde_dpo,
              &via_dpo);
}

void
bier_disp_entry_path_add (index_t bdei,
                          bier_hdr_proto_id_t pproto,
                          const fib_route_path_t *rpaths)
{
    fib_node_index_t *pli, old_pli;
    bier_disp_entry_t *bde;

    bde = bier_disp_entry_get(bdei);
    pli = &bde->bde_pl[pproto];
    old_pli = *pli;

    /*
     * create a new or update the existing path-list for this
     * payload protocol
     */
    if (FIB_NODE_INDEX_INVALID == *pli)
    {
        *pli = fib_path_list_create((FIB_PATH_LIST_FLAG_SHARED |
                                     FIB_PATH_LIST_FLAG_NO_URPF),
                                    rpaths);
    }
    else
    {
        *pli = fib_path_list_copy_and_path_add(old_pli,
                                               (FIB_PATH_LIST_FLAG_SHARED |
                                                FIB_PATH_LIST_FLAG_NO_URPF),
                                               rpaths);
    }

    fib_path_list_lock(*pli);
    fib_path_list_unlock(old_pli);

    bier_disp_entry_restack(bde, pproto);
}

int
bier_disp_entry_path_remove (index_t bdei,
                             bier_hdr_proto_id_t pproto,
                             const fib_route_path_t *rpaths)
{
    fib_node_index_t *pli, old_pli;
    bier_disp_entry_t *bde;

    bde = bier_disp_entry_get(bdei);
    pli = &bde->bde_pl[pproto];
    old_pli = *pli;

    /*
     * update the existing path-list for this payload protocol
     */
    if (FIB_NODE_INDEX_INVALID != *pli)
    {
        *pli = fib_path_list_copy_and_path_remove(old_pli,
                                                  (FIB_PATH_LIST_FLAG_SHARED |
                                                   FIB_PATH_LIST_FLAG_NO_URPF),
                                                  rpaths);

        fib_path_list_lock(*pli);
        fib_path_list_unlock(old_pli);

        bier_disp_entry_restack(bde, pproto);
    }

    /*
     * if there are no path-list defined for any payload protocol
     * then this entry is OK for removal
     */
    int remove = 1;

    FOR_EACH_BIER_HDR_PROTO(pproto)
    {
        if (FIB_NODE_INDEX_INVALID != bde->bde_pl[pproto])
        {
            remove = 0;
            break;
        }
    }

    return (remove);
}

u8*
format_bier_disp_entry (u8* s, va_list *args)
{
    index_t bdei = va_arg (*args, index_t);
    u32 indent = va_arg(*args, u32);
    bier_show_flags_t flags = va_arg(*args, bier_show_flags_t);
    bier_hdr_proto_id_t pproto;
    bier_disp_entry_t *bde;

    bde = bier_disp_entry_get(bdei);

    s = format(s, "%Ubier-disp:[%d]", format_white_space, indent, bdei);

    FOR_EACH_BIER_HDR_PROTO(pproto)
    {
        if (INDEX_INVALID != bde->bde_pl[pproto])
        {
            s = format(s, "\n%U%U\n",
                       format_white_space, indent+2,
                       format_bier_hdr_proto, pproto);
            s = format(s, "%U", format_fib_path_list, bde->bde_pl[pproto], indent+4);

            if (flags & BIER_SHOW_DETAIL)
            {
                s = format(s, "\n%UForwarding:",
                           format_white_space, indent+4);
                s = format(s, "\n%Urpf-id:%d",
                           format_white_space, indent+6,
                           bde->bde_fwd[pproto].bde_rpf_id);
                s = format(s, "\n%U%U",
                           format_white_space, indent+6,
                           format_dpo_id, &bde->bde_fwd[pproto].bde_dpo, indent+2);
            }
        }
    }
    return (s);
}

void
bier_disp_entry_contribute_forwarding (index_t bdei,
                                       dpo_id_t *dpo)
{
    dpo_set(dpo, DPO_BIER_DISP_ENTRY, DPO_PROTO_BIER, bdei);
}

const static char* const bier_disp_entry_bier_nodes[] =
{
    "bier-disp-dispatch",
    NULL,
};

const static char* const * const bier_disp_entry_nodes[DPO_PROTO_NUM] =
{
    [DPO_PROTO_BIER]  = bier_disp_entry_bier_nodes,
};

static void
bier_disp_entry_dpo_lock (dpo_id_t *dpo)
{
    bier_disp_entry_lock(dpo->dpoi_index);
}

static void
bier_disp_entry_dpo_unlock (dpo_id_t *dpo)
{
    bier_disp_entry_unlock(dpo->dpoi_index);
}

static void
bier_disp_entry_dpo_mem_show (void)
{
    fib_show_memory_usage("BIER disposition",
                          pool_elts(bier_disp_entry_pool),
                          pool_len(bier_disp_entry_pool),
                          sizeof(bier_disp_entry_t));
}

static u8*
format_bier_disp_entry_dpo (u8* s, va_list *ap)
{
    index_t index = va_arg(*ap, index_t);
    u32 indent = va_arg(*ap, u32);

    s = format(s, "%U", format_bier_disp_entry, index, indent, BIER_SHOW_DETAIL);

    return (s);
}

const static dpo_vft_t bier_disp_entry_vft = {
    .dv_lock = bier_disp_entry_dpo_lock,
    .dv_unlock = bier_disp_entry_dpo_unlock,
    .dv_format = format_bier_disp_entry_dpo,
    .dv_mem_show = bier_disp_entry_dpo_mem_show,
};

clib_error_t *
bier_disp_entry_db_module_init (vlib_main_t *vm)
{
    dpo_register(DPO_BIER_DISP_ENTRY,
                 &bier_disp_entry_vft,
                 bier_disp_entry_nodes);

    return (NULL);
}

VLIB_INIT_FUNCTION (bier_disp_entry_db_module_init);

static clib_error_t *
show_bier_disp_entry (vlib_main_t * vm,
               unformat_input_t * input,
               vlib_cli_command_t * cmd)
{
    index_t bdei;

    bdei = INDEX_INVALID;

    while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
        if (unformat (input, "%d", &bdei))
            ;
        else
        {
            break;
        }
    }

    if (INDEX_INVALID == bdei)
    {
        return (NULL);
    }
    else
    {
        if (pool_is_free_index(bier_disp_entry_pool, bdei))
        {
            vlib_cli_output(vm, "No such BIER disp entry: %d", bdei);
        }
        else
        {
            vlib_cli_output(vm, "%U", format_bier_disp_entry, bdei, 1,
                            BIER_SHOW_DETAIL);
        }
    }
    return (NULL);
}

VLIB_CLI_COMMAND (show_bier_disp_entry_node, static) = {
    .path = "show bier disp entry",
    .short_help = "show bier disp entry index",
    .function = show_bier_disp_entry,
};