From ff69c24a5e977be7a773ee5c99b6f8bf436f016e Mon Sep 17 00:00:00 2001 From: Flavio Leitner Date: Fri, 11 Apr 2014 18:34:14 -0300 Subject: [PATCH] ofproto/xlate: Move is_admissible() up No functional changes. This is just for better readability when the multicast snooping learning and sending functions are added to the code. Acked-by: Thomas Graf Acked-by: Daniel Borkmann Signed-off-by: Flavio Leitner Signed-off-by: Ben Pfaff --- ofproto/ofproto-dpif-xlate.c | 120 +++++++++++++++++------------------ 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index f08d1ecbc14..86566ad66eb 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -1306,6 +1306,66 @@ is_gratuitous_arp(const struct flow *flow, struct flow_wildcards *wc) } } +/* Determines whether packets in 'flow' within 'xbridge' should be forwarded or + * dropped. Returns true if they may be forwarded, false if they should be + * dropped. + * + * 'in_port' must be the xport that corresponds to flow->in_port. + * 'in_port' must be part of a bundle (e.g. in_port->bundle must be nonnull). + * + * 'vlan' must be the VLAN that corresponds to flow->vlan_tci on 'in_port', as + * returned by input_vid_to_vlan(). It must be a valid VLAN for 'in_port', as + * checked by input_vid_is_valid(). + * + * May also add tags to '*tags', although the current implementation only does + * so in one special case. + */ +static bool +is_admissible(struct xlate_ctx *ctx, struct xport *in_port, + uint16_t vlan) +{ + struct xbundle *in_xbundle = in_port->xbundle; + const struct xbridge *xbridge = ctx->xbridge; + struct flow *flow = &ctx->xin->flow; + + /* Drop frames for reserved multicast addresses + * only if forward_bpdu option is absent. */ + if (!xbridge->forward_bpdu && eth_addr_is_reserved(flow->dl_dst)) { + xlate_report(ctx, "packet has reserved destination MAC, dropping"); + return false; + } + + if (in_xbundle->bond) { + struct mac_entry *mac; + + switch (bond_check_admissibility(in_xbundle->bond, in_port->ofport, + flow->dl_dst)) { + case BV_ACCEPT: + break; + + case BV_DROP: + xlate_report(ctx, "bonding refused admissibility, dropping"); + return false; + + case BV_DROP_IF_MOVED: + ovs_rwlock_rdlock(&xbridge->ml->rwlock); + mac = mac_learning_lookup(xbridge->ml, flow->dl_src, vlan); + if (mac && mac->port.p != in_xbundle->ofbundle && + (!is_gratuitous_arp(flow, &ctx->xout->wc) + || mac_entry_is_grat_arp_locked(mac))) { + ovs_rwlock_unlock(&xbridge->ml->rwlock); + xlate_report(ctx, "SLB bond thinks this packet looped back, " + "dropping"); + return false; + } + ovs_rwlock_unlock(&xbridge->ml->rwlock); + break; + } + } + + return true; +} + /* Checks whether a MAC learning update is necessary for MAC learning table * 'ml' given that a packet matching 'flow' was received on 'in_xbundle' in * 'vlan'. @@ -1421,66 +1481,6 @@ update_learning_table(const struct xbridge *xbridge, } } -/* Determines whether packets in 'flow' within 'xbridge' should be forwarded or - * dropped. Returns true if they may be forwarded, false if they should be - * dropped. - * - * 'in_port' must be the xport that corresponds to flow->in_port. - * 'in_port' must be part of a bundle (e.g. in_port->bundle must be nonnull). - * - * 'vlan' must be the VLAN that corresponds to flow->vlan_tci on 'in_port', as - * returned by input_vid_to_vlan(). It must be a valid VLAN for 'in_port', as - * checked by input_vid_is_valid(). - * - * May also add tags to '*tags', although the current implementation only does - * so in one special case. - */ -static bool -is_admissible(struct xlate_ctx *ctx, struct xport *in_port, - uint16_t vlan) -{ - struct xbundle *in_xbundle = in_port->xbundle; - const struct xbridge *xbridge = ctx->xbridge; - struct flow *flow = &ctx->xin->flow; - - /* Drop frames for reserved multicast addresses - * only if forward_bpdu option is absent. */ - if (!xbridge->forward_bpdu && eth_addr_is_reserved(flow->dl_dst)) { - xlate_report(ctx, "packet has reserved destination MAC, dropping"); - return false; - } - - if (in_xbundle->bond) { - struct mac_entry *mac; - - switch (bond_check_admissibility(in_xbundle->bond, in_port->ofport, - flow->dl_dst)) { - case BV_ACCEPT: - break; - - case BV_DROP: - xlate_report(ctx, "bonding refused admissibility, dropping"); - return false; - - case BV_DROP_IF_MOVED: - ovs_rwlock_rdlock(&xbridge->ml->rwlock); - mac = mac_learning_lookup(xbridge->ml, flow->dl_src, vlan); - if (mac && mac->port.p != in_xbundle->ofbundle && - (!is_gratuitous_arp(flow, &ctx->xout->wc) - || mac_entry_is_grat_arp_locked(mac))) { - ovs_rwlock_unlock(&xbridge->ml->rwlock); - xlate_report(ctx, "SLB bond thinks this packet looped back, " - "dropping"); - return false; - } - ovs_rwlock_unlock(&xbridge->ml->rwlock); - break; - } - } - - return true; -} - static void xlate_normal(struct xlate_ctx *ctx) {