예제 #1
0
파일: valve_flood.py 프로젝트: Baloc/faucet
 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
예제 #2
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
예제 #3
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
예제 #4
0
def build_output_actions(output_dict):
    """Implement actions to alter packet/output."""
    output_actions = []
    output_port = None
    ofmsgs = []
    # if destination rewriting selected, rewrite it.
    if 'dl_dst' in output_dict:
        output_actions.append(valve_of.set_eth_dst(output_dict['dl_dst']))
    # rewrite any VLAN headers.
    vlan_actions = rewrite_vlan(output_dict)
    if vlan_actions:
        output_actions.extend(vlan_actions)
    if 'port' in output_dict:
        output_port = output_dict['port']
        output_actions.append(valve_of.output_port(output_port))
    if 'failover' in output_dict:
        failover = output_dict['failover']
        group_id = failover['group_id']
        buckets = []
        for port in failover['ports']:
            buckets.append(
                valve_of.bucket(watch_port=port,
                                actions=[valve_of.output_port(port)]))
        ofmsgs.append(valve_of.groupdel(group_id=group_id))
        ofmsgs.append(valve_of.groupadd_ff(group_id=group_id, buckets=buckets))
        output_actions.append(valve_of.group_act(group_id=group_id))
    return (output_port, output_actions, ofmsgs)
예제 #5
0
파일: valve_route.py 프로젝트: Baloc/faucet
 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
예제 #6
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