Esempio n. 1
0
 def _add_faucet_fib_to_vip(self, vlan, priority, faucet_vip, faucet_vip_host):
     learn_connected_priority = self.route_priority + faucet_vip.network.prefixlen
     faucet_mac = vlan.faucet_mac
     insts = [valve_of.goto_table(self.fib_table)]
     if self._global_routing():
         vlan_mac = valve_packet.int_in_mac(faucet_mac, vlan.vid)
         insts = [valve_of.apply_actions([
             valve_of.set_eth_dst(vlan_mac),
             valve_of.set_vlan_vid(self.global_vlan.vid)])] + insts
     ofmsgs = []
     ofmsgs.append(self.eth_src_table.flowmod(
         self.eth_src_table.match(eth_type=self.ETH_TYPE, eth_dst=faucet_mac, vlan=vlan),
         priority=self.route_priority,
         inst=insts))
     routed_vlans = self._routed_vlans(vlan)
     if self._global_routing():
         vlan = self.global_vlan
     ofmsgs.append(self.fib_table.flowmod(
         self._route_match(vlan, faucet_vip_host),
         priority=priority,
         inst=[valve_of.goto_table(self.vip_table)]))
     if self.proactive_learn and not faucet_vip.ip.is_link_local:
         for routed_vlan in routed_vlans:
             ofmsgs.append(self.fib_table.flowmod(
                 self._route_match(routed_vlan, faucet_vip),
                 priority=learn_connected_priority,
                 inst=[valve_of.goto_table(self.vip_table)]))
         ofmsgs.append(self.vip_table.flowcontroller(
             self.vip_table.match(eth_type=self.ETH_TYPE),
             priority=priority-1,
             max_len=self.MAX_LEN))
     return ofmsgs
Esempio n. 2
0
 def _nexthop_actions(self, eth_dst, vlan):
     ofmsgs = []
     if self.routers:
         ofmsgs.append(valve_of.set_vlan_vid(vlan.vid))
     ofmsgs.extend([
         valve_of.set_eth_src(self.faucet_mac),
         valve_of.set_eth_dst(eth_dst),
         valve_of.dec_ip_ttl()])
     return ofmsgs
Esempio n. 3
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
 def _add_faucet_fib_to_vip(self, vlan, priority, faucet_vip,
                            faucet_vip_host):
     learn_connected_priority = self.route_priority + faucet_vip.network.prefixlen
     faucet_mac = vlan.faucet_mac
     insts = [valve_of.goto_table(self.fib_table)]
     if self._global_routing():
         vlan_mac = faucet_mac.split(':')[:4] + [
             '%x' % (vlan.vid >> 8),
             '%x' % (vlan.vid & 0xff)
         ]
         vlan_mac = ':'.join(vlan_mac)
         insts = [
             valve_of.apply_actions([
                 valve_of.set_eth_dst(vlan_mac),
                 valve_of.set_vlan_vid(self.global_vlan.vid)
             ])
         ] + insts
     ofmsgs = []
     ofmsgs.append(
         self.eth_src_table.flowmod(self.eth_src_table.match(
             eth_type=self.ETH_TYPE, eth_dst=faucet_mac, vlan=vlan),
                                    priority=self.route_priority,
                                    inst=insts))
     routed_vlans = self._routed_vlans(vlan)
     if self._global_routing():
         vlan = self.global_vlan
     ofmsgs.append(
         self.fib_table.flowmod(self._route_match(vlan, faucet_vip_host),
                                priority=priority,
                                inst=[valve_of.goto_table(self.vip_table)]))
     if self.proactive_learn and faucet_vip.ip not in self.LINK_LOCAL:
         for routed_vlan in routed_vlans:
             ofmsgs.append(
                 self.fib_table.flowmod(
                     self._route_match(routed_vlan, faucet_vip),
                     priority=learn_connected_priority,
                     inst=[valve_of.goto_table(self.vip_table)]))
         ofmsgs.append(
             self.vip_table.flowcontroller(
                 self.vip_table.match(eth_type=self.ETH_TYPE),
                 priority=priority - 1,
                 max_len=self.MAX_LEN))
     return ofmsgs