Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create sdk-vpp chain element for creating loopback interface attached to the fib table #364

Closed
denis-tingaikin opened this issue Sep 2, 2021 · 5 comments · Fixed by #532
Assignees
Labels
ASAP As soon as possible enhancement New feature or request Planning Issue related to SOW
Milestone

Comments

@denis-tingaikin
Copy link
Member

denis-tingaikin commented Sep 2, 2021

Depends on

#341

Context

networkservicemesh/cmd-nse-vl3-vpp#1

Description

We need to

  1. create a loopback interface attached to the fib table
  2. assign its IP address to the loopback interface.
  3. program a route in the fib table to the SrcIP for the NSC connecting and point out the interface.
@denis-tingaikin denis-tingaikin added enhancement New feature or request Planning Issue related to SOW ASAP As soon as possible labels Sep 2, 2021
@denis-tingaikin denis-tingaikin added this to the v1.1.0 milestone Sep 2, 2021
@glazychev-art glazychev-art self-assigned this Sep 10, 2021
@glazychev-art
Copy link
Contributor

glazychev-art commented Sep 13, 2021

I would like to show my understanding of vl3 and loopback interface.

Chain (modification of this):

...
point2pointipam.NewServer(ipnet),
iptable.NewServer(),   // - #1
loopback.NewServer(),  // - #2
mechanisms.NewServer(map[string]networkservice.NetworkServiceServer{
	memif.MECHANISM: chain.NewNetworkServiceServer(
		sendfd.NewServer(),
		up.NewServer(ctx, vppConn),
		mtu.NewServer(vppConn),        //
		routes.NewServer(vppConn),     //
		unnumbered.NewServer(vppConn), // - #3
		tag.NewServer(ctx, vppConn),
		memif.NewServer(vppConn),
	),
}),
...

1. iptable
Creates an ip-table (if doesn't exist) for a given NetworkService.
Does:
-Stores tableId in metadata.
-Checks - if NetworkService usage counter is 0 - deletes ip-table

2. loopback
Creates an loopback interface (if doesn't exist) for a given tableID (from iptable metadata).
Does:
-Stores loopback swIfIndex in metadata.
-Adds itself to ip-table (from iptable metadata).
-Assigns IP-address to itself (from connection.GetContext().GetIpContext())
-Checks - if ip-table usage counter is 0 - deletes loopback interface.

3. unnumbered
New chain element. Sets unnumbered interface.
These elements:

		mtu.NewServer(vppConn),       
		routes.NewServer(vppConn),  
		ipaddress.NewServer(vppConn),

constitute connectioncontext chain element.
I suggest to replace ipaddress -> unnumbered in vl3 endpoint.
Does:
Sets unnumbered interface (gets loopback swIfIndex and ifindex from metadata).

Addition
I think, it would be better to use ipaddress chain in step 2 to set ip-address for the loopback. But we need to change chain element for that, because it uses ifindex.Load(...) inside. For example, as workaround, add flag like this:

...
ipaddress.NewServer(..., isUsedForLoopback)
loopback.NewServer(), 
...

@edwarnicke
Copy link
Member

  1. Could we rename 'iptable' to 'vrf' so as not to confuse it with the linux iptables. Other than naming you are completely right :)
  2. Your loopback sounds right :)
  3. unnumbered is also good :)

One 'Additions' I'd suggest simply giving ipaddress.NewServer the Options pattern with an Option like:

func WithLoadSwIfIndex(func(ctx context.Context, isClient bool) (value interface_types.InterfaceIndex, ok bool)) Option {...}

Default to using the ifindex.Load function ... but then you can optionall override it with another Load.

One thing to keep in mind though... do we want to keep resetting the IP on the loopback with each new connection (even if its the same value)?

@edwarnicke
Copy link
Member

Also... how are you getting ipam for the dst IP for the loopback since you only need it once?

@glazychev-art
Copy link
Contributor

I don't quite understand. Why do we need to reset IP address with new connection?

@glazychev-art
Copy link
Contributor

#364 (comment)
That's a good question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ASAP As soon as possible enhancement New feature or request Planning Issue related to SOW
Projects
None yet
3 participants