예제 #1
0
 def add_faucet_vip(self, vlan, faucet_vip):
     ofmsgs = []
     faucet_vip_host = ipaddr.IPNetwork(faucet_vip.ip)
     max_prefixlen = faucet_vip_host.prefixlen
     priority = self.route_priority + max_prefixlen
     ofmsgs.append(
         self.valve_flowmod(
             self.eth_src_table,
             self.valve_in_match(self.eth_src_table,
                                 eth_type=self._eth_type(),
                                 vlan=vlan,
                                 nw_proto=inet.IPPROTO_ICMPV6,
                                 ipv6_nd_target=faucet_vip_host,
                                 icmpv6_type=icmpv6.ND_NEIGHBOR_SOLICIT),
             priority=priority,
             inst=[
                 valve_of.apply_actions([valve_of.output_controller()]),
                 valve_of.goto_table(self.eth_dst_table)
             ]))
     ofmsgs.append(
         self.valve_flowmod(
             self.eth_src_table,
             self.valve_in_match(self.eth_src_table,
                                 eth_type=self._eth_type(),
                                 eth_dst=self.faucet_mac,
                                 vlan=vlan,
                                 nw_proto=inet.IPPROTO_ICMPV6,
                                 icmpv6_type=icmpv6.ND_NEIGHBOR_ADVERT),
             priority=priority,
             inst=[
                 valve_of.apply_actions([valve_of.output_controller()]),
                 valve_of.goto_table(self.eth_dst_table)
             ]))
     # Initialize IPv6 FIB
     ofmsgs.append(
         self.valve_flowmod(self.eth_src_table,
                            self.valve_in_match(self.eth_src_table,
                                                eth_type=self._eth_type(),
                                                eth_dst=self.faucet_mac,
                                                vlan=vlan),
                            priority=self.route_priority,
                            inst=[valve_of.goto_table(self.fib_table)]))
     ofmsgs.append(
         self.valve_flowcontroller(
             self.fib_table,
             self.valve_in_match(self.fib_table,
                                 eth_type=self._eth_type(),
                                 vlan=vlan,
                                 nw_proto=inet.IPPROTO_ICMPV6,
                                 nw_dst=faucet_vip_host,
                                 icmpv6_type=icmpv6.ICMPV6_ECHO_REQUEST),
             priority=priority))
     return ofmsgs
예제 #2
0
 def add_faucet_vip(self, vlan, faucet_vip):
     ofmsgs = []
     faucet_vip_net = ipaddr.IPNetwork(faucet_vip.exploded)
     faucet_vip_host = ipaddr.IPNetwork(faucet_vip.ip)
     max_prefixlen = faucet_vip_host.prefixlen
     priority = self.route_priority + max_prefixlen
     ofmsgs.append(self.valve_flowmod(
         self.eth_src_table,
         self.valve_in_match(
             self.eth_src_table,
             eth_type=self._eth_type(),
             vlan=vlan,
             nw_proto=inet.IPPROTO_ICMPV6,
             ipv6_nd_target=faucet_vip_host,
             icmpv6_type=icmpv6.ND_NEIGHBOR_SOLICIT),
         priority=priority,
         inst=[valve_of.apply_actions([valve_of.output_controller()]),
               valve_of.goto_table(self.eth_dst_table)]))
     ofmsgs.append(self.valve_flowmod(
         self.eth_src_table,
         self.valve_in_match(
             self.eth_src_table,
             eth_type=self._eth_type(),
             eth_dst=self.faucet_mac,
             vlan=vlan,
             nw_proto=inet.IPPROTO_ICMPV6,
             icmpv6_type=icmpv6.ND_NEIGHBOR_ADVERT),
         priority=priority,
         inst=[valve_of.apply_actions([valve_of.output_controller()]),
               valve_of.goto_table(self.eth_dst_table)]))
     # Initialize IPv6 FIB
     ofmsgs.append(self.valve_flowmod(
         self.eth_src_table,
         self.valve_in_match(
             self.eth_src_table,
             eth_type=self._eth_type(),
             eth_dst=self.faucet_mac,
             vlan=vlan),
         priority=self.route_priority,
         inst=[valve_of.goto_table(self.fib_table)]))
     ofmsgs.append(self.valve_flowcontroller(
         self.fib_table,
         self.valve_in_match(
             self.fib_table,
             eth_type=self._eth_type(),
             vlan=vlan,
             nw_proto=inet.IPPROTO_ICMPV6,
             nw_dst=faucet_vip_host,
             icmpv6_type=icmpv6.ICMPV6_ECHO_REQUEST),
         priority=priority))
     return ofmsgs
예제 #3
0
 def _add_faucet_vip_nd(self, vlan, priority, faucet_vip, faucet_vip_host):
     faucet_vip_host_nd_mcast = valve_packet.ipv6_link_eth_mcast(
         valve_packet.ipv6_solicited_node_from_ucast(faucet_vip.ip))
     controller_and_flood = [
         valve_of.apply_actions([valve_of.output_controller()]),
         valve_of.goto_table(self.flood_table)]
     ofmsgs = []
     ofmsgs.append(self.eth_src_table.flowmod(
         self.eth_src_table.match(
             eth_type=self.ETH_TYPE,
             eth_dst=faucet_vip_host_nd_mcast,
             vlan=vlan,
             nw_proto=inet.IPPROTO_ICMPV6,
             icmpv6_type=icmpv6.ND_NEIGHBOR_SOLICIT),
         priority=priority,
         inst=controller_and_flood))
     ofmsgs.append(self.eth_src_table.flowcontroller(
         self.eth_src_table.match(
             eth_type=self.ETH_TYPE,
             eth_dst=vlan.faucet_mac,
             vlan=vlan,
             nw_proto=inet.IPPROTO_ICMPV6,
             icmpv6_type=icmpv6.ND_NEIGHBOR_ADVERT),
         priority=priority))
     if faucet_vip.ip in valve_packet.IPV6_LINK_LOCAL:
         ofmsgs.append(self.eth_src_table.flowmod(
             self.eth_src_table.match(
                 eth_type=self.ETH_TYPE,
                 eth_dst=valve_packet.IPV6_ALL_ROUTERS_MCAST,
                 vlan=vlan,
                 nw_proto=inet.IPPROTO_ICMPV6,
                 icmpv6_type=icmpv6.ND_ROUTER_SOLICIT),
             priority=priority,
             inst=controller_and_flood))
     return ofmsgs
예제 #4
0
 def valve_flowcontroller(self, table_id, match=None, priority=None,
                          inst=None):
     if inst is None:
         inst = []
     return self.valve_flowmod(
         table_id,
         match=match,
         priority=priority,
         inst=[valve_of.apply_actions(
             [valve_of.output_controller()])] + inst)
예제 #5
0
 def flowcontroller(self, match=None, priority=None, inst=None, max_len=96):
     """Add flow outputting to controller."""
     if inst is None:
         inst = []
     return self.flowmod(
         match=match,
         priority=priority,
         inst=[
             valve_of.apply_actions([valve_of.output_controller(max_len)])
         ] + inst)
예제 #6
0
 def valve_flowcontroller(self, table_id, match=None, priority=None,
                          inst=None):
     """Add flow outputting to controller."""
     if inst is None:
         inst = []
     return self.valve_flowmod(
         table_id,
         match=match,
         priority=priority,
         inst=[valve_of.apply_actions(
             [valve_of.output_controller()])] + inst)
예제 #7
0
 def add_faucet_vip(self, vlan, faucet_vip):
     ofmsgs = []
     max_prefixlen = faucet_vip.ip.max_prefixlen
     faucet_vip_host = self._host_from_faucet_vip(faucet_vip)
     priority = self.route_priority + max_prefixlen
     learn_connected_priority = self.route_priority + faucet_vip.network.prefixlen
     ofmsgs.append(self.valve_flowmod(
         self.eth_src_table,
         self.valve_in_match(
             self.eth_src_table,
             eth_type=ether.ETH_TYPE_ARP,
             nw_dst=faucet_vip_host,
             vlan=vlan),
         priority=priority,
         inst=[valve_of.apply_actions([valve_of.output_controller()])]))
     # Initialize IPv4 FIB
     ofmsgs.append(self.valve_flowmod(
         self.eth_src_table,
         self.valve_in_match(
             self.eth_src_table,
             eth_type=self.ETH_TYPE,
             eth_dst=self.faucet_mac,
             vlan=vlan),
         priority=self.route_priority,
         inst=[valve_of.goto_table(self.fib_table)]))
     ofmsgs.append(self.valve_flowcontroller(
         self.fib_table,
         self.valve_in_match(
             self.fib_table,
             vlan=vlan,
             eth_type=self.ETH_TYPE,
             nw_proto=inet.IPPROTO_ICMP,
             nw_src=faucet_vip,
             nw_dst=faucet_vip_host),
         priority=priority))
     if self.proactive_learn:
         ofmsgs.append(self.valve_flowcontroller(
             self.fib_table,
             self.valve_in_match(
                 self.fib_table,
                 vlan=vlan,
                 eth_type=self.ETH_TYPE,
                 nw_dst=faucet_vip),
             priority=learn_connected_priority))
     return ofmsgs
예제 #8
0
 def add_faucet_vip(self, vlan, faucet_vip):
     ofmsgs = []
     faucet_vip_net = ipaddr.IPNetwork(faucet_vip.exploded)
     faucet_vip_host = ipaddr.IPNetwork(faucet_vip.ip)
     max_prefixlen = faucet_vip_host.prefixlen
     priority = self.route_priority + max_prefixlen
     ofmsgs.append(
         self.valve_flowmod(self.eth_src_table,
                            self.valve_in_match(self.eth_src_table,
                                                eth_type=ether.ETH_TYPE_ARP,
                                                nw_dst=faucet_vip_host,
                                                vlan=vlan),
                            priority=priority,
                            inst=[
                                valve_of.apply_actions(
                                    [valve_of.output_controller()]),
                                valve_of.goto_table(self.eth_dst_table)
                            ]))
     # Initialize IPv4 FIB
     ofmsgs.append(
         self.valve_flowmod(self.eth_src_table,
                            self.valve_in_match(self.eth_src_table,
                                                eth_type=self._eth_type(),
                                                eth_dst=self.faucet_mac,
                                                vlan=vlan),
                            priority=self.route_priority,
                            inst=[valve_of.goto_table(self.fib_table)]))
     ofmsgs.append(
         self.valve_flowcontroller(self.fib_table,
                                   self.valve_in_match(
                                       self.fib_table,
                                       vlan=vlan,
                                       eth_type=self._eth_type(),
                                       nw_proto=inet.IPPROTO_ICMP,
                                       nw_src=faucet_vip_net,
                                       nw_dst=faucet_vip_host),
                                   priority=priority))
     return ofmsgs
예제 #9
0
파일: valve_route.py 프로젝트: Baloc/faucet
 def add_faucet_vip(self, vlan, faucet_vip):
     ofmsgs = []
     faucet_vip_net = ipaddr.IPNetwork(faucet_vip.exploded)
     faucet_vip_host = ipaddr.IPNetwork(faucet_vip.ip)
     max_prefixlen = faucet_vip_host.prefixlen
     priority = self.route_priority + max_prefixlen
     ofmsgs.append(self.valve_flowmod(
         self.eth_src_table,
         self.valve_in_match(
             self.eth_src_table,
             eth_type=ether.ETH_TYPE_ARP,
             nw_dst=faucet_vip_host,
             vlan=vlan),
         priority=priority,
         inst=[valve_of.apply_actions([valve_of.output_controller()]),
               valve_of.goto_table(self.eth_dst_table)]))
     # Initialize IPv4 FIB
     ofmsgs.append(self.valve_flowmod(
         self.eth_src_table,
         self.valve_in_match(
             self.eth_src_table,
             eth_type=self._eth_type(),
             eth_dst=self.faucet_mac,
             vlan=vlan),
         priority=self.route_priority,
         inst=[valve_of.goto_table(self.fib_table)]))
     ofmsgs.append(self.valve_flowcontroller(
         self.fib_table,
         self.valve_in_match(
             self.fib_table,
             vlan=vlan,
             eth_type=self._eth_type(),
             nw_proto=inet.IPPROTO_ICMP,
             nw_src=faucet_vip_net,
             nw_dst=faucet_vip_host),
         priority=priority))
     return ofmsgs
예제 #10
0
 def add_faucet_vip(self, vlan, faucet_vip):
     ofmsgs = []
     max_prefixlen = faucet_vip.ip.max_prefixlen
     faucet_vip_host = self._host_from_faucet_vip(faucet_vip)
     priority = self.route_priority + max_prefixlen
     learn_connected_priority = self.route_priority + faucet_vip.network.prefixlen
     faucet_vip_host_nd_mcast = valve_packet.ipv6_link_eth_mcast(
         valve_packet.ipv6_solicited_node_from_ucast(faucet_vip.ip))
     ofmsgs.append(
         self.valve_flowmod(
             self.eth_src_table,
             self.valve_in_match(self.eth_src_table,
                                 eth_type=self.ETH_TYPE,
                                 vlan=vlan,
                                 nw_proto=inet.IPPROTO_ICMPV6,
                                 eth_dst=faucet_vip_host_nd_mcast,
                                 icmpv6_type=icmpv6.ND_NEIGHBOR_SOLICIT),
             priority=priority,
             inst=[
                 valve_of.apply_actions([valve_of.output_controller()]),
                 valve_of.goto_table(self.flood_table)
             ]))
     ofmsgs.append(
         self.valve_flowmod(
             self.eth_src_table,
             self.valve_in_match(self.eth_src_table,
                                 eth_type=self.ETH_TYPE,
                                 eth_dst=self.faucet_mac,
                                 vlan=vlan,
                                 nw_proto=inet.IPPROTO_ICMPV6,
                                 icmpv6_type=icmpv6.ND_NEIGHBOR_ADVERT),
             priority=priority,
             inst=[valve_of.apply_actions([valve_of.output_controller()])]))
     if faucet_vip.ip in valve_packet.IPV6_LINK_LOCAL:
         ofmsgs.append(
             self.valve_flowmod(
                 self.eth_src_table,
                 self.valve_in_match(
                     self.eth_src_table,
                     eth_type=self.ETH_TYPE,
                     vlan=vlan,
                     nw_proto=inet.IPPROTO_ICMPV6,
                     eth_dst=valve_packet.IPV6_ALL_ROUTERS_MCAST,
                     icmpv6_type=icmpv6.ND_ROUTER_SOLICIT),
                 priority=priority,
                 inst=[
                     valve_of.apply_actions([valve_of.output_controller()]),
                     valve_of.goto_table(self.flood_table)
                 ]))
     # Initialize IPv6 FIB
     ofmsgs.append(
         self.valve_flowmod(self.eth_src_table,
                            self.valve_in_match(self.eth_src_table,
                                                eth_type=self.ETH_TYPE,
                                                eth_dst=self.faucet_mac,
                                                vlan=vlan),
                            priority=self.route_priority,
                            inst=[valve_of.goto_table(self.fib_table)]))
     ofmsgs.append(
         self.valve_flowcontroller(
             self.fib_table,
             self.valve_in_match(self.fib_table,
                                 eth_type=self.ETH_TYPE,
                                 vlan=vlan,
                                 nw_proto=inet.IPPROTO_ICMPV6,
                                 nw_dst=faucet_vip_host,
                                 icmpv6_type=icmpv6.ICMPV6_ECHO_REQUEST),
             priority=priority,
             max_len=128))
     if self.proactive_learn:
         ofmsgs.append(
             self.valve_flowcontroller(self.fib_table,
                                       self.valve_in_match(
                                           self.fib_table,
                                           vlan=vlan,
                                           eth_type=self.ETH_TYPE,
                                           nw_dst=faucet_vip),
                                       priority=learn_connected_priority))
     return ofmsgs