Git Product home page Git Product logo

srv6-net-prog's Introduction

SREXT

SREXT is a kernel module providing the basic Segment Routing functions in addition to more advanced ones. It can be used as a standalone SRv6 implementation or as a complement to the existing SRv6 kernel implementation (kernel 4.10 and later kernels).

This is the project web page, part of the ROSE project.

SREXT supports “my local SID table” which contains the local SRv6 segments explicitly instantiated in the node and associates each SID with a function. The local SID table is completely independent from the Linux routing table and contains only SRv6 segments. Each entry of the localsid table is an SRv6 segment that is associated with an SRv6 endpoint behavior.

SREXT registers a callback function in the pre-routing hook of the netfilter framework. This callback function is invoked for each received IPv6 packet. If the destination address of the IPv6 packet matches an entry in the local SID table, the associated behavior is applied otherwise the packet will go through the kernel's routing sub-system for normal processing.

SREXT support most endpoint behaviors of the I-D.ietf-spring-srv6-network-programming by associating a different function to different SRv6 segments. The following table summarize the currently implemented SRv6 endpoint behaviors.

+-------------+--------------------------------------------------------------------------------+
| BEHAVIOR    |                                  Desription                                    |
|-------------+--------------------------------------------------------------------------------+
|  End        | The Endpoint function ("End" for short) is the most basic function             |
|-------------+--------------------------------------------------------------------------------+
|  End.X      | Endpoint with cross-connect to an array of layer-3 adjacencies                 |
|-------------+--------------------------------------------------------------------------------+
|  End.DX2    | Endpoint with decapsulation and Layer-2 cross-connect to OIF                   |
|-------------+--------------------------------------------------------------------------------+
|  End.Dx4    | Endpoint with decapsulation and cross-connect to an IPv4 adjacency             |
|-------------+--------------------------------------------------------------------------------+
|  End.DX6    | Endpoint with decapsulation and cross-connect to an IPv6 adjacency             |
|-------------+--------------------------------------------------------------------------------+
|  End.AD4    | Endpoint to IPv4 SR-unaware APP via dynamic proxy                              |
|-------------+--------------------------------------------------------------------------------+
|  End.AD6    | Endpoint to IPv6 SR-unaware APP via dynamic proxy                              |
|-------------+--------------------------------------------------------------------------------+
|  End.AM     | Endpoint to SR-unaware APP via masquerading                                    |
|-------------+--------------------------------------------------------------------------------+
|  End.EAD4   | Extended End.AD4 behavior that allow SR-unaware VNFS to be the last SF in SFC  |
|-------------+--------------------------------------------------------------------------------+
|  End.EAD6   | Extended End.AD6 behavior that allow SR-unaware VNFS to be the last SF in SFC  |
+-------------+--------------------------------------------------------------------------------+

I. Compilation and Installation

Clone srv6-net-prog repository in your machine:

$ git clone https://github.com/netgroup/SRv6-net-prog 

Compile srext module and CLI

$ cd srv6-net-prog/srext/
$ sudo make 

Install srext module and CLI

$ sudo make install

Deinstall srext module and CLI

$ sudo rmmod srext
$ sudo make deinstall
$ sudo make clean

II. Usage

SREXT provides a command-line interface to interact with the local SID table, for adding a new SID, removing an existing SID, showing its content and more. Some examples of the CLI syntax is shown hereafter

Loading srext module

$ sudo depmod -a
$ sudo modprobe srext

srext CLI

$ sudo srconf localsid
Usage: srconf localsid { help | flush }
       srconf localsid { show | clear-counters } [SID]
       srconf localsid del SID
       srconf localsid add SID BEHAVIOUR
BEHAVIOUR:= { end |
              end.dx2 TARGETIF |
              end.dx4 NEXTHOP4 TARGETIF |
              { end.x | end.dx6 } NEXTHOP6 TARGETIF |
              { end.ad4 | end.ead4 } NEXTHOP4 TARGETIF SOURCEIF |
              { end.am | end.ad6 | end.ead6 } NEXTHOP6 TARGETIF SOURCEIF |
              end.as4 NEXTHOP4 TARGETIF SOURCEIF src ADDR segs SIDLIST left SEGMENTLEFT }
              end.as6 NEXTHOP6 TARGETIF SOURCEIF src ADDR segs SIDLIST left SEGMENTLEFT |
NEXTHOP4:= { ip IPv4-ADDR | mac MAC-ADDR }
NEXTHOP6:= { ip IPv6-ADDR | mac MAC-ADDR }

- Adding a new SID to “my localsid table”

Let's take an example of adding a SID with End.AM behavior. The End.AM behavioris used mostly is SFC use cases. It supports service chaining through SR-unaware application.

$ sudo srconf localsid add SID end.am ip IPv6-ADDR TARGETIF SOURCEIF

SID: SRv6 segment

IP-ADDR: IPv6 address of the VNF

TARGETIF: Target interface is used to trnsmmit packets to the VNF (after Masquerading)

SOURCEIF: Source interface identifies packets coming back from the VNF (to be de-masqueraded)

- Deleting and existing SID from “my localsid table”

$ sudo srconf localsid del SID 

If you want to delete all SIDs of the local SId table, you can use the flush command instead

$ sudo srconf localsid flush 

- Printing the SIDs of “my localsid table”

The show command prints SIDs of “my localsid table”, and shows, for each SID, the associated behavior, attributes, and counters for both good and bad traffic

The show command comes in two variants;

- show all SIDs of my local SID table
$ sudo srconf localsid show 
- show specific SID from my local SID table
$ sudo srconf localsid show SID

Here an example output of the show command for all SIDs:

$ sudo srconf localsid show
SRv6 - MY LOCALSID TABLE:
======================================================= 
  SID     :        2::AD6:F1  
  Behavior:        end.ad6  
  Next hop:        2:f1::f1  
  OIF     :        veth1-2-f1   
  IIF     :        veth1-2-f1   
  Good traffic:    [33 packets : 3894  bytes]  
  Bad traffic:     [0 packets : 0  bytes]
 ------------------------------------------------------   
  SID     :        2::AD6:F2  
  Behavior:        end.ad6
  Next hop:        00:00:00:02:f3:f3   
  OIF     :        veth1-2-f2   
  IIF     :        veth1-2-f2   
  Good traffic:    [33 packets : 3894  bytes]  
  Bad traffic:     [0 packets : 0  bytes]
 ------------------------------------------------------ 
  SID     :        2::D6:3
  Behavior:        end.dx6  
  Next hop:        2:3::3
  OIF     :        eth2   
  Good traffic:    [33 packets : 3894  bytes]  
  Bad traffic:     [0 packets : 0  bytes]
  ------------------------------------------------------

SID counters

SREXT ClI provides, for each SID, counters for both good and bad traffic that match with each SID. The counters are printed in the output of the show command.

SREXT gives the ability to clear the SID conuters using the clear-counters command

The clear-counters command comes in two variants;

- clear counters of all SIDs of my local SID table
$ sudo srconf localsid clear-counters 
- clear counters of specific SID from my local SID table
$ sudo srconf localsid clear-counters SID

Testbed - SFC use-case

we provide a VirtualBox testbed using Vagrant. The testbed gives an example of using the srext module to support the chaining of SR-unaware VNFs use-case.

For a complete description of the use-case, please visit the testbed page

 

srv6-net-prog's People

Contributors

ahsalam avatar dutsai avatar pierventre avatar stefanosalsano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

srv6-net-prog's Issues

4.19.82 Kernel usage error

executing the srconf localsid add 1 :: 2 end.dx4 ip 0.0.0.0 br-lan command,
the host cannot ping 1 :: 2 and prompts a kernel error
[SREXT][Error] End.DX4 - Packet has no inner IPv4 header, dropped.

make failed in Kernel 5.2 and later

in the kernel version 5.2.x and later, the struct genl_ops delete filed "policy", this will cause make failed.
the new definition is:

/**
 * struct genl_ops - generic netlink operations
 * @cmd: command identifier
 * @internal_flags: flags used by the family
 * @flags: flags
 * @doit: standard command callback
 * @start: start callback for dumps
 * @dumpit: callback for dumpers
 * @done: completion callback for dumps
 */
struct genl_ops {
	int		       (*doit)(struct sk_buff *skb,
				       struct genl_info *info);
	int		       (*start)(struct netlink_callback *cb);
	int		       (*dumpit)(struct sk_buff *skb,
					 struct netlink_callback *cb);
	int		       (*done)(struct netlink_callback *cb);
	u8			cmd;
	u8			internal_flags;
	u8			flags;
	u8			validate;
};

Processing time of packets with srv6

Hi,

Is there any way to measure the time of these SRv6 functions? for example, if I want to know the exact time of arrival of the package on some interface, the time it takes for the kernel to match ipv6 da and build the srv6 extension and the time that package left the interface for the destination host. How can I do that?

with iptables

the packet via end.dx4 cannot seems to be masqueraded by '-t nat' rule of iptabes ip masquerade. Is it a behavior you expect?

SRv6 support on linux

Hi guys,

I have a little problem. I have 3 linux hosts with ubuntu 20 (I already tried debian 10 and fedora). And I'm trying to make srv6 work on these hosts. The environment looks something like this:
host 1:
ip -6 route add fe80::3 encap seg6 mode inline segs fe80::2 dev enp0s8

host 2: receives the package. but after that, nothing is happening. I want host 2 to forward the packet to host 3. Why isn't this happening?
echo 100 localsid >> /etc/iproute2/rt_tables
ip -6 rule add to fe80::/64 lookup localsid
ip -6 route add blackhole default table localsid
ip -6 route add fe80::/64 encap seg6local action End dev enp0s8 table localsid

File sr_nfv_connector.box not found on http://cs.gssi.infn.it/files/SFC/

Hi,

It seems http://cs.gssi.infn.it/files/SFC/sr_nfv_connector.box is not available. It is used in the VNF example. Vagrant fails with an error:

ubuntu@blade04:~/SRv6-net-prog$ vagrant box add sr-vnf http://cs.gssi.infn.it/files/SFC/sr_nfv_connector.box==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'sr-vnf' (v0) for provider: 
    box: Downloading: http://cs.gssi.infn.it/files/SFC/sr_nfv_connector.box
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

The requested URL returned error: 404 Not Found
ubuntu@blade04:~/SRv6-net-prog$

Same error when using a web browser. Any suggestions what to do?

SRv6-net-prog testbed seems to be broken

When running vagrant and virtualbox the make of Srext fails on a error. Full output when command is run on the made vagrant machine:

sr6@srv6-net-prog:~/test/SRv6-net-prog/srext$ sudo make sudo make deinstall make -C kernel/ deinstall make[1]: Entering directory '/home/sr6/test/SRv6-net-prog/srext/kernel' sudo rm -rf /lib/modules/4.10.0-041000-generic/extra/srext* make[1]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext/kernel' make -C tools/ deinstall make[1]: Entering directory '/home/sr6/test/SRv6-net-prog/srext/tools' rm -rf /usr/bin/srconf make[1]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext/tools' make clean make[1]: Entering directory '/home/sr6/test/SRv6-net-prog/srext' make -C kernel/ clean make[2]: Entering directory '/home/sr6/test/SRv6-net-prog/srext/kernel' rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c *.markers *.symvers *.order .*.o.d .tmp_versions make[2]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext/kernel' make -C tools/ clean make[2]: Entering directory '/home/sr6/test/SRv6-net-prog/srext/tools' rm -rf ../bin/srconf make[2]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext/tools' make[1]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext' make -C kernel/ make[1]: Entering directory '/home/sr6/test/SRv6-net-prog/srext/kernel' make -C /lib/modules/4.10.0-041000-generic/build EXTRA_CFLAGS="-I /home/sr6/test/SRv6-net-prog/srext/kernel/../include" M=/home/sr6/test/SRv6-net-prog/srext/kernel modules make[2]: Entering directory '/usr/src/linux-headers-4.10.0-041000-generic' CC [M] /home/sr6/test/SRv6-net-prog/srext/kernel/sr_hook.o CC [M] /home/sr6/test/SRv6-net-prog/srext/kernel/sr_genl.o CC [M] /home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.o /home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.c: In function ‘ip6_route_input’: /home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.c:47:66: warning: passing argument 4 of ‘ip6_route_input_lookup’ makes integer from pointer without a cast skb_dst_set(skb, ip6_route_input_lookup(net, skb->dev, &fl6, skb, flags)); ^ In file included from /home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.c:17:0: ./include/net/ip6_route.h:68:19: note: expected ‘int’ but argument is of type ‘struct sk_buff *’ struct dst_entry *ip6_route_input_lookup(struct net *net, ^ /home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.c:47:22: error: too many arguments to function ‘ip6_route_input_lookup’ skb_dst_set(skb, ip6_route_input_lookup(net, skb->dev, &fl6, skb, flags)); ^ In file included from /home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.c:17:0: ./include/net/ip6_route.h:68:19: note: declared here struct dst_entry *ip6_route_input_lookup(struct net *net, ^ scripts/Makefile.build:294: recipe for target '/home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.o' failed make[3]: *** [/home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.o] Error 1 Makefile:1496: recipe for target '_module_/home/sr6/test/SRv6-net-prog/srext/kernel' failed make[2]: *** [_module_/home/sr6/test/SRv6-net-prog/srext/kernel] Error 2 make[2]: Leaving directory '/usr/src/linux-headers-4.10.0-041000-generic' Makefile:12: recipe for target 'default' failed make[1]: *** [default] Error 2 make[1]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext/kernel' Makefile:3: recipe for target 'default' failed make: *** [default] Error 2 sr6@srv6-net-prog:~/test/SRv6-net-prog/srext$ sudo make install make -C kernel/ install make[1]: Entering directory '/home/sr6/test/SRv6-net-prog/srext/kernel' make -C /lib/modules/4.10.0-041000-generic/build M=/home/sr6/test/SRv6-net-prog/srext/kernel modules_install make[2]: Entering directory '/usr/src/linux-headers-4.10.0-041000-generic' DEPMOD 4.10.0-041000-generic make[2]: Leaving directory '/usr/src/linux-headers-4.10.0-041000-generic' make[1]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext/kernel' make -C tools/ install make[1]: Entering directory '/home/sr6/test/SRv6-net-prog/srext/tools' cp ../bin/srconf /usr/bin cp: cannot stat ‘../bin/srconf’: No such file or directory Makefile:7: recipe for target 'install' failed make[1]: *** [install] Error 1 make[1]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext/tools' Makefile:9: recipe for target 'install' failed make: *** [install] Error 2 sr6@srv6-net-prog:~/test/SRv6-net-prog/srext$ sudo make sudo make deinstall make -C kernel/ deinstall make[1]: Entering directory '/home/sr6/test/SRv6-net-prog/srext/kernel' sudo rm -rf /lib/modules/4.10.0-041000-generic/extra/srext* make[1]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext/kernel' make -C tools/ deinstall make[1]: Entering directory '/home/sr6/test/SRv6-net-prog/srext/tools' rm -rf /usr/bin/srconf make[1]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext/tools' make clean make[1]: Entering directory '/home/sr6/test/SRv6-net-prog/srext' make -C kernel/ clean make[2]: Entering directory '/home/sr6/test/SRv6-net-prog/srext/kernel' rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c *.markers *.symvers *.order .*.o.d .tmp_versions make[2]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext/kernel' make -C tools/ clean make[2]: Entering directory '/home/sr6/test/SRv6-net-prog/srext/tools' rm -rf ../bin/srconf make[2]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext/tools' make[1]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext' make -C kernel/ make[1]: Entering directory '/home/sr6/test/SRv6-net-prog/srext/kernel' make -C /lib/modules/4.10.0-041000-generic/build EXTRA_CFLAGS="-I /home/sr6/test/SRv6-net-prog/srext/kernel/../include" M=/home/sr6/test/SRv6-net-prog/srext/kernel modules make[2]: Entering directory '/usr/src/linux-headers-4.10.0-041000-generic' CC [M] /home/sr6/test/SRv6-net-prog/srext/kernel/sr_hook.o CC [M] /home/sr6/test/SRv6-net-prog/srext/kernel/sr_genl.o CC [M] /home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.o /home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.c: In function ‘ip6_route_input’: /home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.c:47:66: warning: passing argument 4 of ‘ip6_route_input_lookup’ makes integer from pointer without a cast skb_dst_set(skb, ip6_route_input_lookup(net, skb->dev, &fl6, skb, flags)); ^ In file included from /home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.c:17:0: ./include/net/ip6_route.h:68:19: note: expected ‘int’ but argument is of type ‘struct sk_buff *’ struct dst_entry *ip6_route_input_lookup(struct net *net, ^ /home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.c:47:22: error: too many arguments to function ‘ip6_route_input_lookup’ skb_dst_set(skb, ip6_route_input_lookup(net, skb->dev, &fl6, skb, flags)); ^ In file included from /home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.c:17:0: ./include/net/ip6_route.h:68:19: note: declared here struct dst_entry *ip6_route_input_lookup(struct net *net, ^ scripts/Makefile.build:294: recipe for target '/home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.o' failed make[3]: *** [/home/sr6/test/SRv6-net-prog/srext/kernel/hook_v4.o] Error 1 Makefile:1496: recipe for target '_module_/home/sr6/test/SRv6-net-prog/srext/kernel' failed make[2]: *** [_module_/home/sr6/test/SRv6-net-prog/srext/kernel] Error 2 make[2]: Leaving directory '/usr/src/linux-headers-4.10.0-041000-generic' Makefile:12: recipe for target 'default' failed make[1]: *** [default] Error 2 make[1]: Leaving directory '/home/sr6/test/SRv6-net-prog/srext/kernel' Makefile:3: recipe for target 'default' failed make: *** [default] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.