srv6-as: fixing coverity issues
[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 service.  This proxy thus
7 receives SR traffic that is formed of an MPLS label stack or an IPv6 header on
8 top of an 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 service (only for inner type IPv4 and
14         IPv6)
15 - IFACE-OUT: Local interface for sending traffic towards the service
16 - IFACE-IN: Local interface receiving the traffic coming back from the service
17 - CACHE: SR information to be attached on the traffic coming back from the
18         service
19
20 A static SR proxy segment is thus defined for a specific service, inner packet
21 type and cached SR information.  It is also bound to a pair of directed
22 interfaces on the proxy.  These may be both directions of a single interface, or
23 opposite directions of two different interfaces.  The latter is recommended in
24 case the service is to be used as part of a bi-directional SR SC policy.  If the
25 proxy and the service both support 802.1Q, IFACE-OUT and IFACE-IN can also
26 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 service.  This SR information
32 corresponds to the full label stack for SR-MPLS or to the encapsulation IPv6
33 header with any 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 service, 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 service on the stream of packets.  It may operate at all
50 protocol layers, terminate transport layer connections, generate new packets and
51 initiate transport layer connections.  This behavior may also be used to
52 integrate an IPv4-only service into an SRv6 policy.  However, a static SR proxy
53 segment can be used in only one service chain at a time.  As opposed to most
54 other segment types, a static SR proxy segment is bound to a unique list of
55 segments, which represents a directed SR SC policy.  This is due to the cached
56 SR information being defined in the segment configuration.  This limitation only
57 prevents multiple segment lists from using the same static SR proxy segment at
58 the same time, but a single segment list can be shared by any number of traffic
59 flows.  Besides, since the returning traffic from the service is re- classified
60 based on the incoming interface, an interface can be used as receiving interface
61 (IFACE-IN) only for a single SR proxy segment at a time.  In the case of a
62 bi-directional SR SC policy, a different SR proxy segment and receiving
63 interface are required for the return direction.
64
65 ## SRv6 pseudocode
66
67 ### Static proxy for inner type Ethernet - End.AS2
68
69 Upon receiving an IPv6 packet destined for S, where S is an End.AS2 SID, a node
70 N does:
71
72 ```
73    1.   IF ENH == 59 THEN                                        ;; Ref1
74    2.       Remove the (outer) IPv6 header and its extension headers
75    3.       Forward the exposed frame on IFACE-OUT
76    4.   ELSE
77    5.       Drop the packet
78 ```
79
80 Ref1: 59 refers to "no next header" as defined by IANA allocation for Internet
81 Protocol Numbers.
82
83 Upon receiving on IFACE-IN an Ethernet frame with a destination address
84 different than the interface address, a node N does:
85
86 ```
87    1.   IF CACHE.SRH THEN                                        ;; Ref2
88    2.       Push CACHE.SRH on top of the existing Ethernet header
89    3.       Set NH value of the pushed SRH to 59
90    4.   Push outer IPv6 header with SA, DA and traffic class from CACHE
91    5.   Set outer payload length and flow label
92    6.   Set NH value to 43 if an SRH was added, or 59 otherwise
93    7.   Lookup outer DA in appropriate table and proceed accordingly
94 ```
95
96 Ref2: CACHE.SRH represents the SRH defined in CACHE, if any, for the static SR
97 proxy segment associated with IFACE-IN.
98
99 The receiving interface must be configured in promiscuous mode in order to
100 accept those Ethernet frames.
101
102 ### Static proxy for inner type IPv4 - End.AS4
103
104 Upon receiving an IPv6 packet destined for S, where S is an End.AS4 SID, a node
105 N does:
106
107 ```
108    1.   IF ENH == 4 THEN                                         ;; Ref1
109    2.       Remove the (outer) IPv6 header and its extension headers
110    3.       Forward the exposed packet on IFACE-OUT towards S-ADDR
111    4.   ELSE
112    5.       Drop the packet
113 ```
114
115 Ref1: 4 refers to IPv4 encapsulation as defined by IANA allocation for Internet
116 Protocol Numbers.
117
118 Upon receiving a non link-local IPv4 packet on IFACE-IN, a node N does:
119
120 ```
121    1.   IF CACHE.SRH THEN                                        ;; Ref2
122    2.       Push CACHE.SRH on top of the existing IPv4 header
123    3.       Set NH value of the pushed SRH to 4
124    4.   Push outer IPv6 header with SA, DA and traffic class from CACHE
125    5.   Set outer payload length and flow label
126    6.   Set NH value to 43 if an SRH was added, or 4 otherwise
127    7.   Decrement inner TTL and update checksum
128    8.   Lookup outer DA in appropriate table and proceed accordingly
129 ```
130
131 Ref2: CACHE.SRH represents the SRH defined in CACHE, if any, for the static SR
132 proxy segment associated with IFACE-IN.
133
134 ### Static proxy for inner type IPv6 - End.AS6
135
136 Upon receiving an IPv6 packet destined for S, where S is an End.AS6 SID, a node
137 N does:
138
139 ```
140    1.   IF ENH == 41 THEN                                        ;; Ref1
141    2.       Remove the (outer) IPv6 header and its extension headers
142    3.       Forward the exposed packet on IFACE-OUT towards S-ADDR
143    4.   ELSE
144    5.       Drop the packet
145 ```
146
147 Ref1: 41 refers to IPv6 encapsulation as defined by IANA allocation for Internet
148 Protocol Numbers.
149
150 Upon receiving a non-link-local IPv6 packet on IFACE-IN, a node N does:
151
152 ```
153    1.   IF CACHE.SRH THEN                                        ;; Ref2
154    2.       Push CACHE.SRH on top of the existing IPv6 header
155    3.       Set NH value of the pushed SRH to 41
156    4.   Push outer IPv6 header with SA, DA and traffic class from CACHE
157    5.   Set outer payload length and flow label
158    6.   Set NH value to 43 if an SRH was added, or 41 otherwise
159    7.   Decrement inner Hop Limit
160    8.   Lookup outer DA in appropriate table and proceed accordingly
161 ```
162
163 Ref2: CACHE.SRH represents the SRH defined in CACHE, if any, for the static SR
164 proxy segment associated with IFACE-IN.
165