Esempio n. 1
0
 def _nexthop_group_buckets(self, vlan, in_port, eth_src):
     actions = self._nexthop_actions(eth_src)
     if not vlan.port_is_tagged(in_port):
         actions.append(valve_of.pop_vlan())
     actions.append(valve_of.output_port(in_port))
     buckets = [valve_of.bucket(actions=actions)]
     return buckets
Esempio n. 2
0
 def _nexthop_group_buckets(self, vlan, in_port, eth_src):
     actions = self._nexthop_actions(eth_src)
     if not vlan.port_is_tagged(in_port):
         actions.append(valve_of.pop_vlan())
     actions.append(valve_of.output_port(in_port))
     buckets = [valve_of.bucket(actions=actions)]
     return buckets
Esempio n. 3
0
 def _build_flood_local_rule_actions(self, vlan, exclude_unicast, in_port):
     flood_acts = []
     tagged_ports = vlan.tagged_flood_ports(exclude_unicast)
     flood_acts.extend(self._build_flood_port_outputs(
         tagged_ports, in_port))
     untagged_ports = vlan.untagged_flood_ports(exclude_unicast)
     if untagged_ports:
         flood_acts.append(valve_of.pop_vlan())
         flood_acts.extend(
             self._build_flood_port_outputs(untagged_ports, in_port))
     return flood_acts
Esempio n. 4
0
 def _build_flood_local_rule_actions(self, vlan, exclude_unicast, in_port):
     flood_acts = []
     tagged_ports = vlan.tagged_flood_ports(exclude_unicast)
     flood_acts.extend(self._build_flood_port_outputs(
         tagged_ports, in_port))
     untagged_ports = vlan.untagged_flood_ports(exclude_unicast)
     if untagged_ports:
         flood_acts.append(valve_of.pop_vlan())
         flood_acts.extend(self._build_flood_port_outputs(
             untagged_ports, in_port))
     return flood_acts
Esempio n. 5
0
 def _build_group_buckets(self, vlan, unicast_flood):
     buckets = []
     for port in vlan.tagged_flood_ports(unicast_flood):
         buckets.append(valve_of.bucket(
             actions=[valve_of.output_port(port.number)]))
     for port in vlan.untagged_flood_ports(unicast_flood):
         buckets.append(valve_of.bucket(
             actions=[
                 valve_of.pop_vlan(),
                 valve_of.output_port(port.number)]))
     return buckets
Esempio n. 6
0
    def build_port_out_inst(self, vlan, port):
        dst_act = []
        if not vlan.port_is_tagged(port) and port.stack is None:
            dst_act.append(valve_of.pop_vlan())
        dst_act.append(valve_of.output_port(port.number))

        if port.mirror is not None:
            mirror_acts = [valve_of.output_port(port.mirror)]
            dst_act.extend(mirror_acts)

        return [valve_of.apply_actions(dst_act)]
Esempio n. 7
0
 def _build_group_buckets(self, vlan, unicast_flood):
     buckets = []
     for port in vlan.tagged_flood_ports(unicast_flood):
         buckets.append(valve_of.bucket(
             actions=[valve_of.output_port(port.number)]))
     for port in vlan.untagged_flood_ports(unicast_flood):
         buckets.append(valve_of.bucket(
             actions=[
                 valve_of.pop_vlan(),
                 valve_of.output_port(port.number)]))
     return buckets
Esempio n. 8
0
    def build_port_out_inst(self, vlan, port):
        dst_act = []
        if not vlan.port_is_tagged(port.number) and port.stack is None:
            dst_act.append(valve_of.pop_vlan())
        dst_act.append(valve_of.output_port(port.number))

        if port.mirror is not None:
            mirror_acts = [valve_of.output_port(port.mirror)]
            dst_act.extend(mirror_acts)

        return [valve_of.apply_actions(dst_act)]
Esempio n. 9
0
 def _build_flood_rule_actions(self, vlan, exclude_unicast, exclude_ports=[]):
     flood_acts = []
     tagged_ports = vlan.tagged_flood_ports(exclude_unicast)
     untagged_ports = vlan.untagged_flood_ports(exclude_unicast)
     for port in tagged_ports:
         if port not in exclude_ports:
             flood_acts.append(valve_of.output_port(port.number))
     if untagged_ports:
         flood_acts.append(valve_of.pop_vlan())
         for port in untagged_ports:
             if port not in exclude_ports:
                 flood_acts.append(valve_of.output_port(port.number))
     return flood_acts
Esempio n. 10
0
def rewrite_vlan(output_dict):
    vlan_actions = []
    if 'pop_vlans' in output_dict:
        for _ in range(output_dict['pop_vlans']):
            vlan_actions.append(valve_of.pop_vlan())
    # if vlan tag is specified, push it.
    if 'vlan_vid' in output_dict:
        vlan_actions.extend(valve_of.push_vlan_act(output_dict['vlan_vid']))
    # or, if a list, push them all (all with type Q).
    elif 'vlan_vids' in output_dict:
        for vid in output_dict['vlan_vids']:
            vlan_actions.extend(valve_of.push_vlan_act(vid))
    return vlan_actions
Esempio n. 11
0
def rewrite_vlan(output_dict):
    """Implement actions to rewrite VLAN headers."""
    vlan_actions = []
    if 'pop_vlans' in output_dict:
        for _ in range(output_dict['pop_vlans']):
            vlan_actions.append(valve_of.pop_vlan())
    # if vlan tag is specified, push it.
    if 'vlan_vid' in output_dict:
        vlan_actions.extend(push_vlan(output_dict['vlan_vid']))
    # swap existing VID
    elif 'swap_vid' in output_dict:
        vlan_actions.append(valve_of.set_vlan_vid(output_dict['swap_vid']))
    # or, if a list, push them all (all with type Q).
    elif 'vlan_vids' in output_dict:
        for vlan_vid in output_dict['vlan_vids']:
            vlan_actions.extend(push_vlan(vlan_vid))
    return vlan_actions
Esempio n. 12
0
    def _update_nexthop(self, vlan, in_port, eth_src, resolved_ip_gw):
        ofmsgs = []
        is_updated = None
        routes = self._vlan_routes(vlan)
        group_mod_method = None
        group_id = None

        nexthop_cache_entry = self._vlan_nexthop_cache_entry(
            vlan, resolved_ip_gw)
        if (nexthop_cache_entry is not None and
                nexthop_cache_entry.eth_src is not None):
            cached_eth_dst = nexthop_cache_entry.eth_src
            if cached_eth_dst != eth_src:
                is_updated = True
                if self.use_group_table:
                    group_mod_method = valve_of.groupmod
                    group_id = self.ip_gw_to_group_id[resolved_ip_gw]
        else:
            is_updated = False
            if self.use_group_table:
                group_mod_method = valve_of.groupadd
                group_id = self._group_id_from_ip_gw(resolved_ip_gw)
                self.ip_gw_to_group_id[resolved_ip_gw] = group_id

        if is_updated is not None:
            if self.use_group_table:
                actions = []
                actions.extend([
                    valve_of.set_eth_src(self.faucet_mac),
                    valve_of.set_eth_dst(eth_src),
                    valve_of.dec_ip_ttl()])
                if not vlan.port_is_tagged(in_port):
                    actions.append(valve_of.pop_vlan())
                actions.append(valve_of.output_port(in_port))
                ofmsgs.append(group_mod_method(
                    group_id=group_id,
                    buckets=[valve_of.bucket(actions=actions)]))

            for ip_dst, ip_gw in routes.iteritems():
                if ip_gw == resolved_ip_gw:
                    ofmsgs.extend(self._add_resolved_route(
                        vlan, ip_gw, ip_dst, eth_src, is_updated))

        self._update_nexthop_cache(vlan, eth_src, resolved_ip_gw)
        return ofmsgs