forked from ovn-org/ovn
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ovn-northd-ddlog: Add IGMP Snooping & Relay
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
- Loading branch information
Showing
8 changed files
with
771 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
import OVN_Northbound as nb | ||
import OVN_Southbound as sb | ||
import ovsdb | ||
import helpers | ||
import lswitch | ||
import lrouter | ||
|
||
function mCAST_DEFAULT_MAX_ENTRIES(): integer = 2048 | ||
|
||
function mCAST_DEFAULT_IDLE_TIMEOUT_S(): integer = 300 | ||
function mCAST_DEFAULT_MIN_IDLE_TIMEOUT_S(): integer = 15 | ||
function mCAST_DEFAULT_MAX_IDLE_TIMEOUT_S(): integer = 3600 | ||
|
||
function mCAST_DEFAULT_MIN_QUERY_INTERVAL_S(): integer = 1 | ||
function mCAST_DEFAULT_MAX_QUERY_INTERVAL_S(): integer = | ||
mCAST_DEFAULT_MAX_IDLE_TIMEOUT_S() | ||
|
||
function mCAST_DEFAULT_QUERY_MAX_RESPONSE_S(): integer = 1 | ||
|
||
/* IP Multicast per switch configuration. */ | ||
relation &McastSwitchCfg( | ||
datapath : uuid, | ||
enabled : bool, | ||
querier : bool, | ||
flood_unreg : bool, | ||
eth_src : string, | ||
ip4_src : string, | ||
table_size : integer, | ||
idle_timeout : integer, | ||
query_interval: integer, | ||
query_max_resp: integer | ||
) | ||
|
||
/* FIXME: Right now table_size is enforced only in ovn-controller but in | ||
* the ovn-northd C version we enforce it on the aggregate groups too. | ||
*/ | ||
|
||
&McastSwitchCfg( | ||
.datapath = ls_uuid, | ||
.enabled = map_get_bool_def(other_config, "mcast_snoop", | ||
false), | ||
.querier = map_get_bool_def(other_config, "mcast_querier", | ||
true), | ||
.flood_unreg = map_get_bool_def(other_config, | ||
"mcast_flood_unregistered", | ||
false), | ||
.eth_src = map_get_str_def(other_config, "mcast_eth_src", ""), | ||
.ip4_src = map_get_str_def(other_config, "mcast_ip4_src", ""), | ||
.table_size = map_get_int_def(other_config, | ||
"mcast_table_size", | ||
mCAST_DEFAULT_MAX_ENTRIES()), | ||
.idle_timeout = idle_timeout, | ||
.query_interval = query_interval, | ||
.query_max_resp = query_max_resp) :- | ||
nb.Logical_Switch(._uuid = ls_uuid, | ||
.other_config = other_config), | ||
var idle_timeout = | ||
map_get_int_def_limit(other_config, "mcast_idle_timeout", | ||
mCAST_DEFAULT_IDLE_TIMEOUT_S(), | ||
mCAST_DEFAULT_MIN_IDLE_TIMEOUT_S(), | ||
mCAST_DEFAULT_MAX_IDLE_TIMEOUT_S()), | ||
var query_interval = | ||
map_get_int_def_limit(other_config, "mcast_query_interval", | ||
idle_timeout / 2, | ||
mCAST_DEFAULT_MIN_QUERY_INTERVAL_S(), | ||
mCAST_DEFAULT_MAX_QUERY_INTERVAL_S()), | ||
var query_max_resp = | ||
map_get_int_def(other_config, "mcast_query_max_response", | ||
mCAST_DEFAULT_QUERY_MAX_RESPONSE_S()). | ||
|
||
/* IP Multicast per router configuration. */ | ||
relation &McastRouterCfg( | ||
datapath: uuid, | ||
relay : bool | ||
) | ||
|
||
&McastRouterCfg(lr_uuid, mcast_relay) :- | ||
nb.Logical_Router(._uuid = lr_uuid, .options = options), | ||
var mcast_relay = map_get_bool_def(options, "mcast_relay", false). | ||
|
||
/* Mapping between Switch and the set of router port uuids on which to flood | ||
* IP multicast for relay. | ||
*/ | ||
relation SwitchMcastFloodRelayPorts(sw: Ref<Switch>, ports: Set<uuid>) | ||
|
||
SwitchMcastFloodRelayPorts(switch, relay_ports) :- | ||
&SwitchPort( | ||
.lsp = lsp, | ||
.sw = switch, | ||
.peer = Some{&RouterPort{.router = &Router{.mcast_cfg = &mcast_cfg}}} | ||
), mcast_cfg.relay, | ||
var lsp_uuid = lsp._uuid, | ||
var relay_ports = Aggregate((switch), group2set(lsp_uuid)). | ||
|
||
SwitchMcastFloodRelayPorts(switch, set_empty()) :- | ||
Switch[switch]. | ||
|
||
/* Relation used to determine if a Switch has at least one router port | ||
* connected to a Router with multicast relay enabled. | ||
*/ | ||
relation SwitchHasMcastFloodRelay(sw: Ref<Switch>, has_flood_relay: bool) | ||
|
||
SwitchHasMcastFloodRelay(switch, not set_is_empty(ports)) :- | ||
SwitchMcastFloodRelayPorts(switch, ports). | ||
|
||
/* Flattened IGMP group. One record per address-port tuple. */ | ||
relation IgmpSwitchGroupPort( | ||
address: string, | ||
switch : Ref<Switch>, | ||
port : uuid | ||
) | ||
|
||
IgmpSwitchGroupPort(address, switch, lsp._uuid) :- | ||
sb.IGMP_Group(.address = address, .datapath = igmp_dp_set, | ||
.ports = pb_ports), | ||
var pb_port_uuid = FlatMap(pb_ports), | ||
port in &SwitchPort(.lsp = lsp, .sw = switch), | ||
sb.Port_Binding(._uuid = pb_port_uuid, .logical_port = lsp.name). | ||
|
||
/* Aggregated IGMP group: merges all IgmpSwitchGroupPort for a given | ||
* address-switch tuple from all chassis. | ||
*/ | ||
relation IgmpSwitchMulticastGroup( | ||
address: string, | ||
switch : Ref<Switch>, | ||
ports : Set<uuid> | ||
) | ||
|
||
IgmpSwitchMulticastGroup(address, switch, ports) :- | ||
IgmpSwitchGroupPort(address, switch, port), | ||
var ports = Aggregate((address, switch), group2set(port)). | ||
|
||
/* Flattened IGMP group representation for routers with relay enabled. One | ||
* record per address-port tuple for all IGMP groups learned by switches | ||
* connected to the router. | ||
*/ | ||
relation IgmpRouterGroupPort( | ||
address: string, | ||
router : Ref<Router>, | ||
port : uuid | ||
) | ||
|
||
IgmpRouterGroupPort(address, rtr_port.router, rtr_port.lrp._uuid) :- | ||
SwitchMcastFloodRelayPorts(switch, sw_flood_ports), | ||
IgmpSwitchMulticastGroup(address, switch, _), | ||
var flood_port = FlatMap(sw_flood_ports), | ||
&SwitchPort(.lsp = lsp, .peer = Some{&rtr_port}), | ||
lsp._uuid == flood_port. | ||
|
||
/* Aggregated IGMP group for routers: merges all IgmpRouterGroupPort for | ||
* a given address-router tuple from all connected switches. | ||
*/ | ||
relation IgmpRouterMulticastGroup( | ||
address: string, | ||
router : Ref<Router>, | ||
ports : Set<uuid> | ||
) | ||
|
||
IgmpRouterMulticastGroup(address, router, ports) :- | ||
IgmpRouterGroupPort(address, router, port), | ||
var ports = Aggregate((address, router), group2set(port)). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.