Esempio n. 1
0
static int
__bridge_table_dump(struct vr_message_dumper *dumper)
{
    struct vr_route_req *req = (struct vr_route_req *)(dumper->dump_req);
    struct vr_route_req resp;
    int ret;
    unsigned int i;
    struct vr_bridge_entry *be;

    for(i = 0; i < (vr_bridge_entries + vr_bridge_oentries); i++) {
        be = (struct vr_bridge_entry *) vr_get_hentry_by_index(vn_rtable, i);
        if (!be) 
            continue;
        if (be->be_flags & VR_BE_FLAG_VALID) {
            if (be->be_key.be_vrf_id != req->rtr_req.rtr_vrf_id)
                continue;
            if (dumper->dump_been_to_marker == 0) {
                if (VR_MAC_CMP(be->be_key.be_mac, req->rtr_req.rtr_mac)
                        && (be->be_key.be_vrf_id == req->rtr_req.rtr_vrf_id)) {
                    dumper->dump_been_to_marker = 1;
                }
            } else {
                if (!bridge_entry_make_req(&resp, be)) {
                    ret = vr_message_dump_object(dumper, VR_ROUTE_OBJECT_ID, &resp);
                    bridge_entry_req_destroy(&resp);
                    if (ret <= 0) {
                        return ret;
                    }
                }
            }
        }
    }

    return 0;
}
Esempio n. 2
0
static int
__mcast_dump(struct vr_message_dumper *dumper)
{
    struct vr_route_req *req = (struct vr_route_req *)(dumper->dump_req);
    struct vr_route_req resp;
    int ret;
    struct vr_mcast_entry *ent;
    unsigned int i;

    for(i = 0; i < (vr_mcast_entries + vr_mcast_oentries); i++) {
        ent = (struct vr_mcast_entry *) vr_get_hentry_by_index(vn_rtable, i);
        if (!ent)
            continue;
        if (ent->flags & VR_MCAST_FLAG_VALID) {
            if (ent->key.vrf_id != req->rtr_req.rtr_vrf_id)
                continue;
            if (dumper->dump_been_to_marker == 0) {
                if ((ent->key.src_ip == (unsigned int)req->rtr_req.rtr_src) &&
                        (ent->key.dst_ip == (unsigned int)req->rtr_req.rtr_prefix) &&
                        (ent->key.vrf_id == req->rtr_req.rtr_vrf_id)) {
                    dumper->dump_been_to_marker = 1;
                }
            } else {
                mcast_make_req(&resp, ent);
                ret = vr_message_dump_object(dumper, VR_ROUTE_OBJECT_ID, &resp);
                if (ret <= 0) 
                    return ret;
            }
        }
    }

    return 0;
}
Esempio n. 3
0
static struct vr_nexthop *
bridge_table_lookup(unsigned int vrf_id, struct vr_route_req *rt)
{
    struct vr_bridge_entry *be;
    struct vr_bridge_entry_key key;

    if (rt->rtr_req.rtr_index != VR_BE_INVALID_INDEX) {
        be = vr_get_hentry_by_index(vn_rtable, rt->rtr_req.rtr_index);
        if (!be)
            return NULL;

        rt->rtr_nh = be->be_nh;
        if (rt->rtr_req.rtr_mac)
            VR_MAC_COPY(rt->rtr_req.rtr_mac, be->be_key.be_mac);

        return rt->rtr_nh;
    }


    rt->rtr_nh = NULL;
    rt->rtr_req.rtr_index = VR_BE_INVALID_INDEX;
    VR_MAC_COPY(key.be_mac, rt->rtr_req.rtr_mac);
    key.be_vrf_id = rt->rtr_req.rtr_vrf_id;

    be = vr_find_bridge_entry(&key);
    if (be) {
        if (be->be_flags & VR_BE_FLAG_LABEL_VALID)
            rt->rtr_req.rtr_label_flags |= VR_RT_LABEL_VALID_FLAG;
        rt->rtr_req.rtr_label = be->be_label;
        rt->rtr_nh = be->be_nh;
        rt->rtr_req.rtr_index = be->be_index;
    }

    return rt->rtr_nh;
}