GBP: redirect contracts
[vpp.git] / src / plugins / srv6-as / as_plugin_doc.md
1 # SRv6 endpoint to SR-unaware appliance via static proxy (End.AS) {#srv6_as_plugin_doc}
2
3 ## Overview
4
5 The static proxy is an SR endpoint behavior for processing SR-MPLS or SRv6
6 encapsulated traffic on behalf of an SR-unaware SF. This proxy thus receives SR
7 traffic that is formed of an MPLS label stack or an IPv6 header on top of an
8 inner packet, which can be Ethernet, IPv4 or IPv6.
9
10 A static SR proxy segment is associated with the following mandatory parameters:
11
12 - INNER-TYPE: Inner packet type
13 - S-ADDR: Ethernet or IP address of the SF (only for inner type IPv4 and IPv6)
14 - IFACE-OUT: Local interface for sending traffic towards the SF
15 - IFACE-IN: Local interface receiving the traffic coming back from the SF
16 - CACHE: SR information to be attached on the traffic coming back from the SF,
17 including at least
18         * CACHE.SA: IPv6 source address (SRv6 only)
19         * CACHE.LIST: Segment list expressed as MPLS labels or IPv6 address
20
21 A static SR proxy segment is thus defined for a specific SF, inner packet type
22 and cached SR information. It is also bound to a pair of directed interfaces on
23 the proxy. These may be both directions of a single interface, or opposite
24 directions of two different interfaces. The latter is recommended in case the SF
25 is to be used as part of a bi-directional SR SC policy. If the proxy and the SF
26 both support 802.1Q, IFACE-OUT and IFACE-IN can also represent sub-interfaces.
27
28 The first part of this behavior is triggered when the proxy node receives a
29 packet whose active segment matches a segment associated with the static proxy
30 behavior. It removes the SR information from the packet then sends it on a
31 specific interface towards the associated SF. This SR information corresponds to
32 the full label stack for SR-MPLS or to the encapsulation IPv6 header with any
33 attached extension header in the case of SRv6.
34
35 The second part is an inbound policy attached to the proxy interface receiving
36 the traffic returning from the SF, IFACE-IN. This policy attaches to the
37 incoming traffic the cached SR information associated with the SR proxy segment.
38 If the proxy segment uses the SR-MPLS data plane, CACHE contains a stack of
39 labels to be pushed on top the packets. With the SRv6 data plane, CACHE is
40 defined as a source address, an active segment and an optional SRH (tag,
41 segments left, segment list and metadata). The proxy encapsulates the packets
42 with an IPv6 header that has the source address, the active segment as
43 destination address and the SRH as a routing extension header. After the SR
44 information has been attached, the packets are forwarded according to the active
45 segment, which is represented by the top MPLS label or the IPv6 Destination
46 Address.
47
48 In this scenario, there are no restrictions on the operations that can be
49 performed by the SF on the stream of packets. It may operate at all protocol
50 layers, terminate transport layer connections, generate new packets and initiate
51 transport layer connections. This behavior may also be used to integrate an
52 IPv4-only SF into an SRv6 policy. However, a static SR proxy segment can be used
53 in only one service chain at a time. As opposed to most other segment types, a
54 static SR proxy segment is bound to a unique list of segments, which represents
55 a directed SR SC policy. This is due to the cached SR information being defined
56 in the segment configuration. This limitation only prevents multiple segment
57 lists from using the same static SR proxy segment at the same time, but a single
58 segment list can be shared by any number of traffic flows. Besides, since the
59 returning traffic from the SF is re-classified based on the incoming interface,
60 an interface can be used as receiving interface (IFACE-IN) only for a single SR
61 proxy segment at a time. In the case of a bi-directional SR SC policy, a
62 different SR proxy segment and receiving interface are required for the return
63 direction.
64
65 For more information, please see
66 [draft-xuclad-spring-sr-service-chaining](https://datatracker.ietf.org/doc/draft-xuclad-spring-sr-service-chaining/).
67
68 ## CLI configuration
69
70 The following command instantiates a new End.AS segment that sends the inner
71 packets on interface `IFACE-OUT` towards an appliance at address `S-ADDR` and
72 restores the segment list ``<S1, S2, S3>`` with a source address `SRC-ADDR` on
73 the packets coming back on interface `IFACE-IN`.
74
75 ```
76 sr localsid address SID behavior end.ad nh S-ADDR oif IFACE-OUT iif IFACE-IN src SRC-ADDR next S1 next S2 next S3
77 ```
78
79 For example, the below command configures the SID `1::A1` with an End.AS
80 function for sending traffic on interface `GigabitEthernet0/8/0` to the
81 appliance at address `A1::`, and receiving it back on interface
82 `GigabitEthernet0/9/0`.
83
84 ```
85 sr localsid address 1::A1 behavior end.ad nh A1:: oif GigabitEthernet0/8/0 iif GigabitEthernet0/9/0 src 1:: next 2::20 next 3::30 next 4::40
86 ```
87
88 ## Pseudocode
89
90 ### Static proxy for inner type IPv4
91
92 Upon receiving an IPv6 packet destined for S, where S is an IPv6 static proxy
93 segment for IPv4 traffic, a node N does:
94
95 ```
96 IF ENH == 4 THEN                                                ;; Ref1
97     Remove the (outer) IPv6 header and its extension headers
98     Forward the exposed packet on IFACE-OUT towards S-ADDR
99 ELSE
100     Drop the packet
101 ```
102
103 **Ref1:** 4 refers to IPv4 encapsulation as defined by IANA allocation for Internet
104 Protocol Numbers.
105
106 Upon receiving a non link-local IPv4 packet on IFACE-IN, a node N does:
107
108 ```
109 Decrement TTL and update checksum
110 IF CACHE.SRH THEN                                               ;; Ref2
111     Push CACHE.SRH on top of the existing IPv4 header
112     Set NH value of the pushed SRH to 4
113 Push outer IPv6 header with SA, DA and traffic class from CACHE
114 Set outer payload length and flow label
115 Set NH value to 43 if an SRH was added, or 4 otherwise
116 Lookup outer DA in appropriate table and proceed accordingly
117 ```
118
119 **Ref2:** CACHE.SRH represents the SRH defined in CACHE, if any, for the static SR
120 proxy segment associated with IFACE-IN.
121
122 ### Static proxy for inner type IPv6
123
124 Upon receiving an IPv6 packet destined for S, where S is an IPv6 static proxy
125 segment for IPv6 traffic, a node N does:
126
127 ```
128 IF ENH == 41 THEN                                               ;; Ref1
129     Remove the (outer) IPv6 header and its extension headers
130     Forward the exposed packet on IFACE-OUT towards S-ADDR
131 ELSE
132     Drop the packet
133 ```
134
135 **Ref1:** 41 refers to IPv6 encapsulation as defined by IANA allocation for Internet
136 Protocol Numbers.
137
138 Upon receiving a non-link-local IPv6 packet on IFACE-IN, a node N does:
139
140 ```
141 Decrement Hop Limit
142 IF CACHE.SRH THEN                                               ;; Ref2
143     Push CACHE.SRH on top of the existing IPv6 header
144     Set NH value of the pushed SRH to 41
145 Push outer IPv6 header with SA, DA and traffic class from CACHE
146 Set outer payload length and flow label
147 Set NH value to 43 if an SRH was added, or 41 otherwise
148 Lookup outer DA in appropriate table and proceed accordingly
149 ```
150
151 **Ref2:** CACHE.SRH represents the SRH defined in CACHE, if any, for the static SR
152 proxy segment associated with IFACE-IN.