Skip to content

Commit

Permalink
poc, kubevirt: Configure mac at arp_proxy
Browse files Browse the repository at this point in the history
Signed-off-by: Enrique Llorente <ellorent@redhat.com>
  • Loading branch information
qinqon committed Feb 13, 2023
1 parent 7a3db91 commit 20d207b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
7 changes: 4 additions & 3 deletions contrib/kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,11 @@ build_ovn_image() {
# Find all built executables, but ignore the 'windows' directory if it exists
find ../../go-controller/_output/go/bin/ -maxdepth 1 -type f -exec cp -f {} . \;
echo "ref: $(git rev-parse --symbolic-full-name HEAD) commit: $(git rev-parse HEAD)" > git_info
OVN_REPO=https://github.com/dceara/ovn
OVN_BRANCH=bz2155306-arp-proxy-poc
OVN_REPO=https://github.com/qinqon/ovn
OVN_BRANCH=arp-proxy-additional-features
OVN_COMMIT=4b987887637fa567562b882445c0bf9daa5c746f
OVN_DOCKERFILE=Dockerfile.fedora.dev
$OCI_BIN build --build-arg OVN_REPO=${OVN_REPO} --build-arg OVN_BRANCH=${OVN_BRANCH} -t "${OVN_IMAGE}" -f ${OVN_DOCKERFILE} .
$OCI_BIN build --build-arg OVN_REPO=${OVN_REPO} --build-arg OVN_BRANCH=${OVN_BRANCH} --build-arg=OVN_COMMIT=${OVN_COMMIT} -t "${OVN_IMAGE}" -f ${OVN_DOCKERFILE} .

# store in local registry
if [ "$KIND_LOCAL_REGISTRY" == true ];then
Expand Down
4 changes: 3 additions & 1 deletion dist/images/Dockerfile.fedora.dev
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ RUN git log -n 1
# Clone OVN Source Code.
ARG OVN_REPO=https://github.com/ovn-org/ovn.git
ARG OVN_BRANCH=main
ARG OVN_COMMIT=HEAD
WORKDIR /root
RUN git clone $OVN_REPO --single-branch --branch=$OVN_BRANCH
RUN git clone $OVN_REPO --single-branch --branch=$OVN_BRANCH && \
cd ovn && git reset --hard $OVN_COMMIT

# Build OVN rpms.
WORKDIR /root/ovn/
Expand Down
16 changes: 14 additions & 2 deletions go-controller/pkg/ovn/base_network_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ func (bnc *BaseNetworkController) syncNodeClusterRouterPort(node *kapi.Node, hos
}
}

// logical router port MAC is based on IPv4 subnet if there is one, else IPv6
var nodeLRPMAC net.HardwareAddr
for _, hostSubnet := range hostSubnets {
gwIfAddr := util.GetNodeGatewayIfAddr(hostSubnet)
nodeLRPMAC = util.IPAddrToHWAddr(gwIfAddr.IP)
if !utilnet.IsIPv6CIDR(hostSubnet) {
break
}
}

switchName := bnc.GetNetworkScopedName(node.Name)
logicalRouterName := bnc.GetNetworkScopedName(types.OVNClusterRouter)
lrpName := types.RouterToSwitchPrefix + switchName
Expand All @@ -221,7 +231,7 @@ func (bnc *BaseNetworkController) syncNodeClusterRouterPort(node *kapi.Node, hos
}
logicalRouterPort := nbdb.LogicalRouterPort{
Name: lrpName,
MAC: "0a:58:0a:f4:00:01",
MAC: nodeLRPMAC.String(),
Networks: lrpNetworks,
}
logicalRouter := nbdb.LogicalRouter{Name: logicalRouterName}
Expand Down Expand Up @@ -317,14 +327,16 @@ func (bnc *BaseNetworkController) createNodeLogicalSwitch(nodeName string, hostS
return fmt.Errorf("failed to add logical switch %+v: %v", logicalSwitch, err)
}

arpProxyMAC := util.IPAddrToHWAddr(net.ParseIP(arpProxyAddress))

// Connect the switch to the router.
logicalSwitchPort := nbdb.LogicalSwitchPort{
Name: types.SwitchToRouterPrefix + switchName,
Type: "router",
Addresses: []string{"router"},
Options: map[string]string{
"router-port": types.RouterToSwitchPrefix + switchName,
"arp_proxy": arpProxyAddress,
"arp_proxy": fmt.Sprintf("%s %s", arpProxyMAC, arpProxyAddress),
},
}
sw := nbdb.LogicalSwitch{Name: switchName}
Expand Down
2 changes: 1 addition & 1 deletion go-controller/pkg/ovn/master_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func addNodeLogicalFlows(testData []libovsdbtest.TestData, expectedOVNClusterRou
UUID: types.SwitchToRouterPrefix + node.Name + "-UUID",
Type: "router",
Options: map[string]string{
"arp_proxy": "169.254.1.1",
"arp_proxy": "0a:58:a9:fe:01:01 169.254.1.1",
"router-port": types.RouterToSwitchPrefix + node.Name,
},
Addresses: []string{"router"},
Expand Down

0 comments on commit 20d207b

Please sign in to comment.