blob: 02eb034a0fdd8c26edc9de54f734f341b6156b3d [file] [log] [blame]
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +05301/*
2 * sfe_ipv6_udp.c
3 * Shortcut forwarding engine file for IPv6 UDP
4 *
5 * Copyright (c) 2015-2016, 2019-2020, The Linux Foundation. All rights reserved.
Guduri Prathyusha5f27e232022-01-06 14:39:04 +05306 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +05307 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21#include <linux/skbuff.h>
22#include <net/udp.h>
23#include <linux/etherdevice.h>
24#include <linux/version.h>
Suruchi Suman23a279d2021-11-16 15:13:09 +053025#include <net/ip6_checksum.h>
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +053026
27#include "sfe_debug.h"
28#include "sfe_api.h"
29#include "sfe.h"
30#include "sfe_flow_cookie.h"
31#include "sfe_ipv6.h"
Guduri Prathyusha79a5fee2021-11-11 17:59:10 +053032#include "sfe_pppoe.h"
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +053033
34/*
Suruchi Suman23a279d2021-11-16 15:13:09 +053035 * sfe_ipv6_udp_sk_deliver()
36 * Deliver the packet to the protocol handler registered with Linux.
37 * To be called under rcu_read_lock()
38 * Returns:
39 * 1 if the packet needs to be passed to Linux.
40 * 0 if the packet is processed successfully.
41 * -1 if the packet is dropped in SFE.
42 */
43static int sfe_ipv6_udp_sk_deliver(struct sk_buff *skb, struct sfe_ipv6_connection_match *cm,
44 unsigned int ihl)
45{
46 int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
47 struct udp_sock *up;
48 struct udphdr *udph;
49 struct sock *sk;
50 int ret;
51
52 /*
53 * Call the decap handler
54 */
55 up = rcu_dereference(cm->up);
56 encap_rcv = READ_ONCE(up->encap_rcv);
57 if (unlikely(!encap_rcv)) {
58 DEBUG_ERROR("sfe: Error: up->encap_rcv is NULL\n");
59 return 1;
60 }
61
62#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0))
63 nf_reset(skb);
64#else
65 nf_reset_ct(skb);
66#endif
67 skb_pull(skb, ihl);
68 skb_reset_transport_header(skb);
69
70 udph = udp_hdr(skb);
71 if (unlikely(skb->ip_summed != CHECKSUM_UNNECESSARY) && unlikely(skb->ip_summed != CHECKSUM_COMPLETE)) {
72 /*
73 * Set Pseudo Checksum using Linux API
74 */
75 if (unlikely(udp6_csum_init(skb, udp_hdr(skb), IPPROTO_UDP))) {
76 DEBUG_ERROR("sfe: udp checksum init() failed: %p\n", skb);
77 kfree_skb(skb);
78 return -1;
79 }
80
81 /*
82 * Verify checksum before giving to encap_rcv handler function.
83 */
84 if (unlikely(udp_lib_checksum_complete(skb))) {
85 DEBUG_ERROR("sfe: Invalid udp checksum: %p\n", skb);
86 kfree_skb(skb);
87 return -1;
88 }
89 }
90
91 /*
92 * Mark that this packet has been fast forwarded.
93 */
94 sk = (struct sock *)up;
95
96 /*
97 * TODO: Find the fix to set skb->ip_summed = CHECKSUM_NONE;
98 */
99
100 /*
101 * encap_rcv() returns the following value:
102 * =0 if skb was successfully passed to the encap
103 * handler or was discarded by it.
104 * >0 if skb should be passed on to UDP.
105 * <0 if skb should be resubmitted as proto -N
106 */
107 ret = encap_rcv(sk, skb);
108 if (unlikely(ret)) {
109
110 /*
111 * If encap_rcv fails, vxlan driver drops the packet.
112 * No need to free the skb here.
113 */
114 DEBUG_ERROR("sfe: udp-decap API return error: %d\n", ret);
115 return -1;
116 }
117
118 DEBUG_TRACE("sfe: udp-decap API encap_rcv successful\n");
119 return 0;
120}
121
122/*
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530123 * sfe_ipv6_recv_udp()
124 * Handle UDP packet receives and forwarding.
125 */
126int sfe_ipv6_recv_udp(struct sfe_ipv6 *si, struct sk_buff *skb, struct net_device *dev,
Ken Zhu88c58152021-12-09 15:12:06 -0800127 unsigned int len, struct ipv6hdr *iph, unsigned int ihl, bool sync_on_find, struct sfe_l2_info *l2_info, bool tun_outer)
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530128{
129 struct udphdr *udph;
130 struct sfe_ipv6_addr *src_ip;
131 struct sfe_ipv6_addr *dest_ip;
132 __be16 src_port;
133 __be16 dest_port;
134 struct sfe_ipv6_connection_match *cm;
135 struct net_device *xmit_dev;
Suruchi Suman23a279d2021-11-16 15:13:09 +0530136 int ret;
Ratheesh Kannotha3cf0e02021-12-09 09:44:10 +0530137 bool hw_csum;
Ratheesh Kannoth71fc51e2022-01-05 10:02:47 +0530138 bool bridge_flow;
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530139
Suruchi Suman23a279d2021-11-16 15:13:09 +0530140 DEBUG_TRACE("%px: sfe: sfe_ipv6_recv_udp called.\n", skb);
141
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530142 /*
143 * Is our packet too short to contain a valid UDP header?
144 */
145 if (!pskb_may_pull(skb, (sizeof(struct udphdr) + ihl))) {
146
147 sfe_ipv6_exception_stats_inc(si,SFE_IPV6_EXCEPTION_EVENT_UDP_HEADER_INCOMPLETE);
148 DEBUG_TRACE("packet too short for UDP header\n");
149 return 0;
150 }
151
152 /*
153 * Read the IP address and port information. Read the IP header data first
154 * because we've almost certainly got that in the cache. We may not yet have
155 * the UDP header cached though so allow more time for any prefetching.
156 */
157 src_ip = (struct sfe_ipv6_addr *)iph->saddr.s6_addr32;
158 dest_ip = (struct sfe_ipv6_addr *)iph->daddr.s6_addr32;
159
160 udph = (struct udphdr *)(skb->data + ihl);
161 src_port = udph->source;
162 dest_port = udph->dest;
163
164 rcu_read_lock();
165
166 /*
167 * Look for a connection match.
168 */
169#ifdef CONFIG_NF_FLOW_COOKIE
170 cm = si->sfe_flow_cookie_table[skb->flow_cookie & SFE_FLOW_COOKIE_MASK].match;
171 if (unlikely(!cm)) {
172 cm = sfe_ipv6_find_connection_match_rcu(si, dev, IPPROTO_UDP, src_ip, src_port, dest_ip, dest_port);
173 }
174#else
175 cm = sfe_ipv6_find_connection_match_rcu(si, dev, IPPROTO_UDP, src_ip, src_port, dest_ip, dest_port);
176#endif
177 if (unlikely(!cm)) {
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530178
Suruchi Suman23a279d2021-11-16 15:13:09 +0530179 /*
180 * Try a 4-tuple lookup; required for tunnels like VxLAN.
181 */
182 cm = sfe_ipv6_find_connection_match_rcu(si, dev, IPPROTO_UDP, src_ip, 0, dest_ip, dest_port);
183 if (unlikely(!cm)) {
184 rcu_read_unlock();
185 sfe_ipv6_exception_stats_inc(si, SFE_IPV6_EXCEPTION_EVENT_UDP_NO_CONNECTION);
186 DEBUG_TRACE("no connection found\n");
187 return 0;
188 }
189 DEBUG_TRACE("sfe: 4-tuple lookup successful\n");
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530190 }
191
192 /*
Suruchi Suman23a279d2021-11-16 15:13:09 +0530193 * If our packet has been marked as "flush on find" we can't actually
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530194 * forward it in the fast path, but now that we've found an associated
Ken Zhu88c58152021-12-09 15:12:06 -0800195 * connection we need sync its status before exception it to slow path.
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530196 */
Ken Zhu88c58152021-12-09 15:12:06 -0800197 if (unlikely(sync_on_find)) {
198 sfe_ipv6_sync_status(si, cm->connection, SFE_SYNC_REASON_STATS);
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530199 rcu_read_unlock();
200
201 sfe_ipv6_exception_stats_inc(si, SFE_IPV6_EXCEPTION_EVENT_UDP_IP_OPTIONS_OR_INITIAL_FRAGMENT);
Ken Zhu88c58152021-12-09 15:12:06 -0800202 DEBUG_TRACE("Sync on find\n");
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530203 return 0;
204 }
205
206#ifdef CONFIG_XFRM
207 /*
208 * We can't accelerate the flow on this direction, just let it go
209 * through the slow path.
210 */
211 if (unlikely(!cm->flow_accel)) {
212 rcu_read_unlock();
213 this_cpu_inc(si->stats_pcpu->packets_not_forwarded64);
214 return 0;
215 }
216#endif
217
Ratheesh Kannoth71fc51e2022-01-05 10:02:47 +0530218 bridge_flow = !!(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_BRIDGE_FLOW);
219
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530220 /*
221 * Does our hop_limit allow forwarding?
222 */
Ratheesh Kannoth71fc51e2022-01-05 10:02:47 +0530223 if (likely(!bridge_flow)) {
224 if (unlikely(iph->hop_limit < 2)) {
Ken Zhu88c58152021-12-09 15:12:06 -0800225 sfe_ipv6_sync_status(si, cm->connection, SFE_SYNC_REASON_STATS);
Ratheesh Kannoth71fc51e2022-01-05 10:02:47 +0530226 rcu_read_unlock();
227
228 sfe_ipv6_exception_stats_inc(si, SFE_IPV6_EXCEPTION_EVENT_UDP_SMALL_TTL);
Ken Zhu88c58152021-12-09 15:12:06 -0800229 DEBUG_TRACE("hop_limit too low\n");
Ratheesh Kannoth71fc51e2022-01-05 10:02:47 +0530230 return 0;
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530231 }
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530232 }
233
234 /*
235 * If our packet is larger than the MTU of the transmit interface then
236 * we can't forward it easily.
237 */
238 if (unlikely(len > cm->xmit_dev_mtu)) {
Ken Zhu88c58152021-12-09 15:12:06 -0800239 sfe_ipv6_sync_status(si, cm->connection, SFE_SYNC_REASON_STATS);
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530240 rcu_read_unlock();
241
242 sfe_ipv6_exception_stats_inc(si, SFE_IPV6_EXCEPTION_EVENT_UDP_NEEDS_FRAGMENTATION);
Ken Zhu88c58152021-12-09 15:12:06 -0800243 DEBUG_TRACE("Larger than MTU\n");
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530244 return 0;
245 }
246
247 /*
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530248 * Check if skb was cloned. If it was, unshare it. Because
249 * the data area is going to be written in this path and we don't want to
250 * change the cloned skb's data section.
251 */
252 if (unlikely(skb_cloned(skb))) {
253 DEBUG_TRACE("%px: skb is a cloned skb\n", skb);
254 skb = skb_unshare(skb, GFP_ATOMIC);
255 if (!skb) {
256 DEBUG_WARN("Failed to unshare the cloned skb\n");
257 rcu_read_unlock();
258 return 0;
259 }
260
261 /*
262 * Update the iph and udph pointers with the unshared skb's data area.
263 */
264 iph = (struct ipv6hdr *)skb->data;
265 udph = (struct udphdr *)(skb->data + ihl);
266 }
267
268 /*
Guduri Prathyusha5f27e232022-01-06 14:39:04 +0530269 * For PPPoE packets, match server MAC and session id
270 */
271 if (unlikely(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_PPPOE_DECAP)) {
272 struct pppoe_hdr *ph;
273 struct ethhdr *eth;
274
275 if (unlikely(!sfe_l2_parse_flag_check(l2_info, SFE_L2_PARSE_FLAGS_PPPOE_INGRESS))) {
276 rcu_read_unlock();
277 DEBUG_TRACE("%px: PPPoE header not present in packet for PPPoE rule\n", skb);
278 sfe_ipv6_exception_stats_inc(si, SFE_IPV6_EXCEPTION_EVENT_INCORRECT_PPPOE_PARSING);
279 return 0;
280 }
281
282 ph = (struct pppoe_hdr *)(skb->head + sfe_l2_pppoe_hdr_offset_get(l2_info));
283 eth = (struct ethhdr *)(skb->head + sfe_l2_hdr_offset_get(l2_info));
284 if (unlikely(cm->pppoe_session_id != ntohs(ph->sid)) || unlikely(!(ether_addr_equal((u8*)cm->pppoe_remote_mac, (u8 *)eth->h_source)))) {
285 DEBUG_TRACE("%px: PPPoE sessions with session IDs %d and %d or server MACs %pM and %pM did not match\n",
286 skb, cm->pppoe_session_id, htons(ph->sid), cm->pppoe_remote_mac, eth->h_source);
287 rcu_read_unlock();
288 sfe_ipv6_exception_stats_inc(si, SFE_IPV6_EXCEPTION_EVENT_INVALID_PPPOE_SESSION);
289 return 0;
290 }
291 skb->protocol = htons(l2_info->protocol);
292 this_cpu_inc(si->stats_pcpu->pppoe_decap_packets_forwarded64);
293
294 } else if (unlikely(sfe_l2_parse_flag_check(l2_info, SFE_L2_PARSE_FLAGS_PPPOE_INGRESS))) {
295
296 /*
297 * If packet contains PPPOE header but CME doesn't contain PPPoE flag yet we are exceptioning the packet to linux
298 */
299 rcu_read_unlock();
300 DEBUG_TRACE("%px: PPPoE is not parsed\n", skb);
301 sfe_ipv6_exception_stats_inc(si, SFE_IPV6_EXCEPTION_EVENT_INCORRECT_PPPOE_PARSING);
302 return 0;
303 }
304
305 /*
306 * From this point on we're good to modify the packet.
307 */
308
309 /*
Guduri Prathyusha79a5fee2021-11-11 17:59:10 +0530310 * For PPPoE flows, add PPPoE header before L2 header is added.
311 */
312 if (cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_PPPOE_ENCAP) {
313 if (unlikely(!sfe_pppoe_add_header(skb, cm->pppoe_session_id, PPP_IPV6))) {
314 rcu_read_unlock();
315 DEBUG_WARN("%px: PPPoE header addition failed\n", skb);
Guduri Prathyusha5f27e232022-01-06 14:39:04 +0530316 sfe_ipv6_exception_stats_inc(si, SFE_IPV6_EXCEPTION_EVENT_NO_HEADROOM);
Guduri Prathyusha79a5fee2021-11-11 17:59:10 +0530317 }
318 this_cpu_inc(si->stats_pcpu->pppoe_encap_packets_forwarded64);
319 }
320
321 /*
322 * TODO: VLAN header should be added here when they are supported.
323 */
324
325 /*
Suruchi Suman23a279d2021-11-16 15:13:09 +0530326 * UDP sock will be valid only in decap-path.
327 * Call encap_rcv function associated with udp_sock in cm.
328 */
329 if (unlikely(cm->up)) {
330
331 /*
332 * Call decap handler associated with sock.
333 * Also validates UDP checksum before calling decap handler.
334 */
335 ret = sfe_ipv6_udp_sk_deliver(skb, cm, ihl);
336 if (unlikely(ret == -1)) {
337 rcu_read_unlock();
338 this_cpu_inc(si->stats_pcpu->packets_dropped64);
339 return 1;
340 } else if (unlikely(ret == 1)) {
341 rcu_read_unlock();
342 this_cpu_inc(si->stats_pcpu->packets_not_forwarded64);
343 return 0;
344 }
345
346 /*
347 * Update traffic stats
348 */
349 atomic_inc(&cm->rx_packet_count);
350 atomic_add(len, &cm->rx_byte_count);
351
352 rcu_read_unlock();
353 this_cpu_inc(si->stats_pcpu->packets_forwarded64);
354 DEBUG_TRACE("%p: sfe: sfe_ipv4_recv_udp -> encap_rcv done.\n", skb);
355 return 1;
356 }
357
358 /*
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530359 * Update DSCP
360 */
361 if (unlikely(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_DSCP_REMARK)) {
362 sfe_ipv6_change_dsfield(iph, cm->dscp);
363 }
364
365 /*
366 * Decrement our hop_limit.
367 */
Ratheesh Kannoth71fc51e2022-01-05 10:02:47 +0530368 if (likely(!bridge_flow)) {
369 iph->hop_limit -= (u8)!tun_outer;
370 }
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530371
372 /*
Ratheesh Kannotha3cf0e02021-12-09 09:44:10 +0530373 * Enable HW csum if rx checksum is verified and xmit interface is CSUM offload capable.
374 * Note: If L4 csum at Rx was found to be incorrect, we (router) should use incremental L4 checksum here
375 * so that HW does not re-calculate/replace the L4 csum
376 */
377 hw_csum = !!(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_CSUM_OFFLOAD) && (skb->ip_summed == CHECKSUM_UNNECESSARY);
378
379 /*
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530380 * Do we have to perform translations of the source address/port?
381 */
382 if (unlikely(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_XLATE_SRC)) {
383 u16 udp_csum;
384
385 iph->saddr.s6_addr32[0] = cm->xlate_src_ip[0].addr[0];
386 iph->saddr.s6_addr32[1] = cm->xlate_src_ip[0].addr[1];
387 iph->saddr.s6_addr32[2] = cm->xlate_src_ip[0].addr[2];
388 iph->saddr.s6_addr32[3] = cm->xlate_src_ip[0].addr[3];
389 udph->source = cm->xlate_src_port;
390
391 /*
392 * Do we have a non-zero UDP checksum? If we do then we need
393 * to update it.
394 */
Ratheesh Kannotha3cf0e02021-12-09 09:44:10 +0530395 if (unlikely(!hw_csum)) {
396 udp_csum = udph->check;
397 if (likely(udp_csum)) {
398 u32 sum = udp_csum + cm->xlate_src_csum_adjustment;
399 sum = (sum & 0xffff) + (sum >> 16);
400 udph->check = (u16)sum;
401 }
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530402 }
403 }
404
405 /*
406 * Do we have to perform translations of the destination address/port?
407 */
408 if (unlikely(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_XLATE_DEST)) {
409 u16 udp_csum;
410
411 iph->daddr.s6_addr32[0] = cm->xlate_dest_ip[0].addr[0];
412 iph->daddr.s6_addr32[1] = cm->xlate_dest_ip[0].addr[1];
413 iph->daddr.s6_addr32[2] = cm->xlate_dest_ip[0].addr[2];
414 iph->daddr.s6_addr32[3] = cm->xlate_dest_ip[0].addr[3];
415 udph->dest = cm->xlate_dest_port;
416
417 /*
418 * Do we have a non-zero UDP checksum? If we do then we need
419 * to update it.
420 */
Ratheesh Kannotha3cf0e02021-12-09 09:44:10 +0530421 if (unlikely(!hw_csum)) {
422 udp_csum = udph->check;
423 if (likely(udp_csum)) {
424 u32 sum = udp_csum + cm->xlate_dest_csum_adjustment;
425 sum = (sum & 0xffff) + (sum >> 16);
426 udph->check = (u16)sum;
427 }
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530428 }
429 }
430
431 /*
Ratheesh Kannotha3cf0e02021-12-09 09:44:10 +0530432 * If HW checksum offload is not possible, incremental L4 checksum is used to update the packet.
433 * Setting ip_summed to CHECKSUM_UNNECESSARY ensures checksum is not recalculated further in packet
434 * path.
435 */
436 if (likely(hw_csum)) {
437 skb->ip_summed = CHECKSUM_PARTIAL;
438 } else {
439 skb->ip_summed = CHECKSUM_UNNECESSARY;
440 }
441
442 /*
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530443 * Update traffic stats.
444 */
445 atomic_inc(&cm->rx_packet_count);
446 atomic_add(len, &cm->rx_byte_count);
447
448 xmit_dev = cm->xmit_dev;
449 skb->dev = xmit_dev;
450
451 /*
452 * Check to see if we need to write a header.
453 */
454 if (likely(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_WRITE_L2_HDR)) {
455 if (unlikely(!(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_WRITE_FAST_ETH_HDR))) {
Guduri Prathyusha5f27e232022-01-06 14:39:04 +0530456 dev_hard_header(skb, xmit_dev, ntohs(skb->protocol),
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530457 cm->xmit_dest_mac, cm->xmit_src_mac, len);
458 } else {
459 /*
460 * For the simple case we write this really fast.
461 */
462 struct ethhdr *eth = (struct ethhdr *)__skb_push(skb, ETH_HLEN);
Guduri Prathyusha5f27e232022-01-06 14:39:04 +0530463 eth->h_proto = skb->protocol;
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530464 ether_addr_copy((u8 *)eth->h_dest, (u8 *)cm->xmit_dest_mac);
465 ether_addr_copy((u8 *)eth->h_source, (u8 *)cm->xmit_src_mac);
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530466 }
467 }
468
469 /*
470 * Update priority of skb.
471 */
472 if (unlikely(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_PRIORITY_REMARK)) {
473 skb->priority = cm->priority;
474 }
475
476 /*
477 * Mark outgoing packet.
478 */
Ken Zhu37040ea2021-09-09 21:11:15 -0700479 if (unlikely(cm->flags & SFE_IPV6_CONNECTION_MATCH_FLAG_MARK)) {
480 skb->mark = cm->mark;
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530481 }
482
483 rcu_read_unlock();
484
485 this_cpu_inc(si->stats_pcpu->packets_forwarded64);
486
487 /*
488 * We're going to check for GSO flags when we transmit the packet so
489 * start fetching the necessary cache line now.
490 */
491 prefetch(skb_shinfo(skb));
492
493 /*
494 * Mark that this packet has been fast forwarded.
495 */
496 skb->fast_forwarded = 1;
497
498 /*
499 * Send the packet on its way.
500 */
501 dev_queue_xmit(skb);
502
503 return 1;
504}