openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/systemd/1_242+AUTOINC+db2e367bfc-r0/git/src/network/networkd-fdb.c
int fdb_entry_configure(Link* link, FdbEntry* fdb_entry)
{
    _cleanup_(sd_netlink_message_unrefp) sd_netlink_message* req = NULL;
    sd_netlink* rtnl;
    int r;
    uint8_t flags;
    Bridge* bridge;

    assert(link);
    assert(link->network);
    assert(link->manager);
    assert(fdb_entry);

    rtnl = link->manager->rtnl;
    bridge = BRIDGE(link->network->bridge);

    /* create new RTM message */
    r = sd_rtnl_message_new_neigh(rtnl, &req, RTM_NEWNEIGH, link->ifindex,
                                  PF_BRIDGE);
    if (r < 0)
        return rtnl_log_create_error(r);

    if (bridge)
        flags = NTF_MASTER;
    else
        flags = NTF_SELF;

    r = sd_rtnl_message_neigh_set_flags(req, flags);
    if (r < 0)
        return rtnl_log_create_error(r);

    /* only NUD_PERMANENT state supported. */
    r = sd_rtnl_message_neigh_set_state(req, NUD_NOARP | NUD_PERMANENT);
    if (r < 0)
        return rtnl_log_create_error(r);

    r = sd_netlink_message_append_ether_addr(req, NDA_LLADDR,
                                             fdb_entry->mac_addr);
    if (r < 0)
        return rtnl_log_create_error(r);

    /* VLAN Id is optional. We'll add VLAN Id only if it's specified. */
    if (0 != fdb_entry->vlan_id)
    {
        r = sd_netlink_message_append_u16(req, NDA_VLAN, fdb_entry->vlan_id);
        if (r < 0)
            return rtnl_log_create_error(r);
    }

    /* send message to the kernel to update its internal static MAC table. */
    r = netlink_call_async(rtnl, NULL, req, set_fdb_handler,
                           link_netlink_destroy_callback, link);
    if (r < 0)
        return log_link_error_errno(link, r,
                                    "Could not send rtnetlink message: %m");

    link_ref(link);

    return 0;
}
/* send a request to the kernel to add a FDB entry in its static MAC table. */
send a request to the kernel to add a FDB entry in its static MAC table.
send a request to the kernel to add a FDB entry in its static MAC table .
int fdb_entry_configure(Link* link, FdbEntry* fdb_entry)
{
    _cleanup_(sd_netlink_message_unrefp) sd_netlink_message* req = NULL;
    sd_netlink* rtnl;
    int r;
    uint8_t flags;
    Bridge* bridge;
    assert(link);
    assert(link->network);
    assert(link->manager);
    assert(fdb_entry);
    rtnl = link->manager->rtnl;
    bridge = BRIDGE(link->network->bridge);
    r = sd_rtnl_message_new_neigh(rtnl, &req, RTM_NEWNEIGH, link->ifindex,
                                  PF_BRIDGE);
    if (r < 0)
        return rtnl_log_create_error(r);
    if (bridge)
        flags = NTF_MASTER;
    else
        flags = NTF_SELF;
    r = sd_rtnl_message_neigh_set_flags(req, flags);
    if (r < 0)
        return rtnl_log_create_error(r);
    r = sd_rtnl_message_neigh_set_state(req, NUD_NOARP | NUD_PERMANENT);
    if (r < 0)
        return rtnl_log_create_error(r);
    r = sd_netlink_message_append_ether_addr(req, NDA_LLADDR,
                                             fdb_entry->mac_addr);
    if (r < 0)
        return rtnl_log_create_error(r);
    if (0 != fdb_entry->vlan_id)
    {
        r = sd_netlink_message_append_u16(req, NDA_VLAN, fdb_entry->vlan_id);
        if (r < 0)
            return rtnl_log_create_error(r);
    }
    r = netlink_call_async(rtnl, NULL, req, set_fdb_handler,
                           link_netlink_destroy_callback, link);
    if (r < 0)
        return log_link_error_errno(link, r,
                                    "Could not send rtnetlink message: %m");
    link_ref(link);
    return 0;
}
int fdb_entry_configure ( Link * link , FdbEntry * fdb_entry ) { _cleanup_ ( sd_netlink_message_unrefp ) sd_netlink_message * req = NULL ; sd_netlink * rtnl ; int r ; uint8_t flags ; Bridge * bridge ; assert ( link ) ; assert ( link -> network ) ; assert ( link -> manager ) ; assert ( fdb_entry ) ; rtnl = link -> manager -> rtnl ; bridge = BRIDGE ( link -> network -> bridge ) ; r = sd_rtnl_message_new_neigh ( rtnl , & req , RTM_NEWNEIGH , link -> ifindex , PF_BRIDGE ) ; if ( r < 0 ) return rtnl_log_create_error ( r ) ; if ( bridge ) flags = NTF_MASTER ; else flags = NTF_SELF ; r = sd_rtnl_message_neigh_set_flags ( req , flags ) ; if ( r < 0 ) return rtnl_log_create_error ( r ) ; r = sd_rtnl_message_neigh_set_state ( req , NUD_NOARP | NUD_PERMANENT ) ; if ( r < 0 ) return rtnl_log_create_error ( r ) ; r = sd_netlink_message_append_ether_addr ( req , NDA_LLADDR , fdb_entry -> mac_addr ) ; if ( r < 0 ) return rtnl_log_create_error ( r ) ; if ( 0 != fdb_entry -> vlan_id ) { r = sd_netlink_message_append_u16 ( req , NDA_VLAN , fdb_entry -> vlan_id ) ; if ( r < 0 ) return rtnl_log_create_error ( r ) ; } r = netlink_call_async ( rtnl , NULL , req , set_fdb_handler , link_netlink_destroy_callback , link ) ; if ( r < 0 ) return log_link_error_errno ( link , r , " " ) ; link_ref ( link ) ; return 0 ; }
send a request to the kernel to add a FDB entry in its static MAC table.
send a request to the kernel to add a FDB entry in its static MAC table .
/* create new RTM message */ /* only NUD_PERMANENT state supported. */ /* VLAN Id is optional. We'll add VLAN Id only if it's specified. */ /* send message to the kernel to update its internal static MAC table. */