Skip to content

Commit

Permalink
add egress routes info to peer update (#2452)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek9686 committed Jul 14, 2023
1 parent 9f59ab8 commit e6c6ec3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions logic/peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
PersistentKeepaliveInterval: &peer.PersistentKeepalive,
ReplaceAllowedIPs: true,
}
if peer.IsEgressGateway {
hostPeerUpdate.EgressRoutes = append(hostPeerUpdate.EgressRoutes, models.EgressNetworkRoutes{
NodeAddr: node.PrimaryAddressIPNet(),
EgressRanges: peer.EgressGatewayRanges,
})
}
if node.IsIngressGateway || node.IsEgressGateway {
if peer.IsIngressGateway {
_, extPeerIDAndAddrs, err := getExtPeers(&peer)
Expand Down
7 changes: 7 additions & 0 deletions models/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type HostPeerUpdate struct {
PeerIDs PeerMap `json:"peerids" bson:"peerids" yaml:"peerids"`
EndpointDetection bool `json:"endpointdetection" yaml:"endpointdetection"`
HostNetworkInfo HostInfoMap `json:"host_network_info,omitempty" bson:"host_network_info,omitempty" yaml:"host_network_info,omitempty"`
EgressRoutes []EgressNetworkRoutes `json:"egress_network_routes"`
}

// IngressInfo - struct for ingress info
Expand All @@ -39,6 +40,12 @@ type EgressInfo struct {
EgressGWCfg EgressGatewayRequest `json:"egress_gateway_cfg" yaml:"egress_gateway_cfg"`
}

// EgressNetworkRoutes - struct for egress network routes for adding routes to peer's interface
type EgressNetworkRoutes struct {
NodeAddr net.IPNet `json:"node_addr"`
EgressRanges []string `json:"egress_ranges"`
}

// PeerRouteInfo - struct for peer info for an ext. client
type PeerRouteInfo struct {
PeerAddr net.IPNet `json:"peer_addr" yaml:"peer_addr"`
Expand Down

0 comments on commit e6c6ec3

Please sign in to comment.