blob: 2120353a9a89104537e5c150c35546de99707651 [file] [log] [blame]
Sundarajan Srinivasan1b03fe22014-12-02 13:20:56 -08001/*
2 **************************************************************************
3 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all copies.
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
13 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 **************************************************************************
15 */
16
17/* nss_ipsecmgr.c
18 * NSS to HLOS IPSec Manager
19 */
20#include <linux/types.h>
21#include <linux/ip.h>
22#include <linux/skbuff.h>
23#include <linux/module.h>
24#include <linux/netdevice.h>
25#include <linux/rtnetlink.h>
26#include <asm/atomic.h>
27#include <nss_api_if.h>
28#include <nss_ipsec.h>
29#include "nss_ipsecmgr.h"
30
31#if defined(CONFIG_DYNAMIC_DEBUG)
32/*
33 * Compile messages for dynamic enable/disable
34 */
35#define nss_ipsecmgr_error(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
36#define nss_ipsecmgr_warn(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
37#define nss_ipsecmgr_info(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
38#define nss_ipsecmgr_trace(s, ...) pr_debug("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__)
39
40#else
41/*
42 * Statically compile messages at different levels
43 */
44#define nss_ipsecmgr_error(s, ...) { \
45 if (NSS_IPSECMGR_DEBUG_LEVEL < NSS_IPSECMGR_DEBUG_LVL_ERROR) { \
46 pr_alert("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
47 } \
48}
49#define nss_ipsecmgr_warn(s, ...) { \
50 if (NSS_IPSECMGR_DEBUG_LEVEL < NSS_IPSECMGR_DEBUG_LVL_WARN) { \
51 pr_warn("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
52 } \
53}
54#define nss_ipsecmgr_info(s, ...) { \
55 if (NSS_IPSECMGR_DEBUG_LEVEL < NSS_IPSECMGR_DEBUG_LVL_INFO) { \
56 pr_notice("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
57 } \
58}
59#define nss_ipsecmgr_trace(s, ...) { \
60 if (NSS_IPSECMGR_DEBUG_LEVEL < NSS_IPSECMGR_DEBUG_LVL_TRACE) { \
61 pr_info("%s[%d]:" s, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
62 } \
63}
64
65#endif /* !CONFIG_DYNAMIC_DEBUG */
66
67/* NSS IPsec entry state */
68enum nss_ipsecmgr_entry_state {
69 NSS_IPSECMGR_ENTRY_STATE_INIT = 0, /* init state of the entry */
70 NSS_IPSECMGR_ENTRY_STATE_VALID = 1, /* entry is valid */
71 NSS_IPSECMGR_ENTRY_STATE_INVALID = 2, /* entry is invalid */
72 NSS_IPSECMGR_ENTRY_STATE_MAX
73};
74
75/* IPsec table entry */
76struct nss_ipsecmgr_tbl_entry {
77 struct nss_ipsec_rule_sel sel; /* rule selector */
78 uint32_t sa_idx; /* index into SA table for this rule */
79 enum nss_ipsecmgr_entry_state state; /* state */
80};
81
82/* NSS IPsec table type */
83struct nss_ipsecmgr_tbl {
84 uint32_t total_tx; /* total packets tx'ed from ENCAP/DECAP */
85 uint32_t total_rx; /* total packets rx'ed at ENCAP/DECAP */
86 uint32_t total_dropped; /* total dropped packets at ENCAP/DECAP */
87 struct nss_ipsecmgr_tbl_entry entry[NSS_IPSEC_MAX_RULES]; /* table entry */
88 uint32_t count; /* number of entries */
89 spinlock_t lock;
90};
91
92/* NSS IPsec SA */
93struct nss_ipsec_sa {
94 atomic_t user; /* reference count */
95 uint32_t esp_spi; /* ESP SPI */
96
97 enum nss_ipsecmgr_rule_type type; /* IPsec rule type (ENCAP/DECAP) */
98
99 struct nss_ipsec_rule_data data; /* IPsec rule data */
100 struct nss_ipsec_sa_stats stats; /* SA statistics */
101};
102
103/* NSS IPsec manager private structure */
104struct nss_ipsecmgr_priv {
105 struct nss_ipsecmgr_tbl encap; /* encap table */
106 struct nss_ipsecmgr_tbl decap; /* decap table */
107 struct nss_ipsec_sa sa_tbl[NSS_IPSEC_MAX_SA]; /* global SA table */
108
109 void *cb_ctx; /* callback context */
110 nss_ipsecmgr_data_cb_t data_cb; /* data callback function */
111 nss_ipsecmgr_event_cb_t event_cb; /* event callback function */
112 struct nss_ctx_instance *nss_ctx; /* NSS context */
113 uint32_t nss_ifnum; /* NSS if num for data */
114};
115
116typedef bool (*nss_ipsecmgr_op_t)(struct net_device *dev, struct nss_ipsecmgr_tbl *tbl, struct nss_ipsec_msg *nim);
117
118/* NSS IPsec manager operation (message types) complete routines */
119struct nss_ipsecmgr_ops {
120 nss_ipsecmgr_op_t verify_fn; /* verify function for the op */
121 nss_ipsecmgr_op_t commit_fn; /* commit function for the op */
122};
123
124/* driver global info */
125struct nss_ipsecmgr_drv {
126 atomic_t sa_count; /* number of SA's available for */
127};
128
129/*
130 **********************
131 * globals
132 **********************
133 */
134
135static struct nss_ipsecmgr_drv gbl_drv_ctx; /* global driver context */
136
137/*
138 **********************
139 * Helper Functions
140 **********************
141 */
142
143/*
144 * nss_ipsecmgr_sa_init()
145 * Initialize SA
146 */
147static void nss_ipsecmgr_sa_init(struct nss_ipsec_sa *sa)
148{
149 memset(sa, 0, sizeof(struct nss_ipsec_sa));
150 atomic_set(&sa->user, 0);
151}
152
153/*
154 * nss_ipsecmgr_sa_get()
155 * Get reference to SA at given index
156 */
157static struct nss_ipsec_sa *nss_ipsecmgr_sa_get(struct nss_ipsec_sa sa_tbl[], uint32_t sa_idx)
158{
159 struct nss_ipsec_sa *sa = &sa_tbl[sa_idx];
160
161 atomic_inc(&sa->user);
162
163 return sa;
164}
165
166/*
167 * nss_ipsecmgr_sa_put()
168 * Release reference to SA at given index
169 */
170static void nss_ipsecmgr_sa_put(struct nss_ipsec_sa sa_tbl[], uint32_t sa_idx)
171{
172 struct nss_ipsec_sa *sa = &sa_tbl[sa_idx];
173
174 if (atomic_read(&sa->user) == 0) {
175 nss_ipsecmgr_error("SA already freed for (%d)\n", sa_idx);
176 return;
177 }
178
179 if (atomic_dec_and_test(&sa->user)) {
180 nss_ipsecmgr_sa_init(sa);
181 }
182}
183
184/*
185 * nss_ipsecmgr_get_type()
186 * Get IPsec manager rule type (encap/decap)
187 */
188static enum nss_ipsecmgr_rule_type nss_ipsecmgr_get_type(uint16_t if_num)
189{
190 switch(if_num) {
191 case NSS_IPSEC_ENCAP_IF_NUMBER:
192 return NSS_IPSECMGR_RULE_TYPE_ENCAP;
193
194 case NSS_IPSEC_DECAP_IF_NUMBER:
195 return NSS_IPSECMGR_RULE_TYPE_DECAP;
196
197 default:
198 return NSS_IPSECMGR_RULE_TYPE_NONE;
199 }
200}
201
202/*
203 * nss_ipsecmgr_get_tbl()
204 * return the table associated with the interface number
205 */
206static inline struct nss_ipsecmgr_tbl *nss_ipsecmgr_get_tbl(struct nss_ipsecmgr_priv *priv, uint16_t if_num)
207{
208 switch (if_num) {
209 case NSS_IPSEC_ENCAP_IF_NUMBER:
210 return &priv->encap;
211
212 case NSS_IPSEC_DECAP_IF_NUMBER:
213 return &priv->decap;
214
215 default:
216 return NULL;
217 }
218}
219
220/*
221 * nss_ipsecmgr_copy_encap_add()
222 * prepare the IPsec message for encap add operation
223 */
224static void nss_ipsecmgr_copy_encap_add(struct net_device *dev, struct nss_ipsec_rule *msg, union nss_ipsecmgr_rule *rule)
225{
226 struct nss_ipsecmgr_encap_add *encap = &rule->encap_add;
227 struct nss_ipsec_rule_sel *sel = &msg->sel;
228 struct nss_ipsec_rule_oip *oip = &msg->oip;
229 struct nss_ipsec_rule_data *data = &msg->data;
230
231 /*
232 * Populate the selectors for encap direction
233 */
234 sel->ipv4_src = encap->inner_ipv4_src;
235 sel->ipv4_dst = encap->inner_ipv4_dst;
236
237 sel->src_port = encap->inner_src_port;
238 sel->dst_port = encap->inner_dst_port;
239
240 sel->ipv4_proto = encap->inner_ipv4_proto;
241
242 /*
243 * Populate the outer IP data for encap direction
244 */
245 oip->ipv4_dst = encap->outer_ipv4_dst;
246 oip->ipv4_src = encap->outer_ipv4_src;
247
248 oip->esp_spi = encap->esp_spi;
249
250 oip->ipv4_ttl = encap->outer_ipv4_ttl;
251
252 /*
253 * Populate the data part
254 */
255 data->cipher_algo = encap->cipher_algo;
256 data->esp_seq_skip = (encap->esp_seq_skip == 1);
257 data->esp_tail_skip = (encap->esp_tail_skip == 1);
258
259 data->esp_icv_len = encap->esp_icv_len;
260 data->auth_algo = encap->auth_algo;
261
262 data->crypto_index = encap->crypto_index;
263
264 data->nat_t_req = encap->nat_t_req;
265 data->use_pattern = encap->use_pattern;
266}
267
268/*
269 * nss_ipsecmgr_copy_decap_add()
270 * prepare the IPsec message for decap add operation
271 */
272static void nss_ipsecmgr_copy_decap_add(struct net_device *dev, struct nss_ipsec_rule *msg, union nss_ipsecmgr_rule *rule)
273{
274 struct nss_ipsecmgr_decap_add *decap = &rule->decap_add;
275 struct nss_ipsec_rule_sel *sel = &msg->sel;
276 struct nss_ipsec_rule_data *data = &msg->data;
277 /*
278 * Populate the selectors for encap direction
279 */
280 sel->ipv4_src = decap->outer_ipv4_src;
281 sel->ipv4_dst = decap->outer_ipv4_dst;
282
283 sel->esp_spi = decap->esp_spi;
284
285 sel->ipv4_proto = IPPROTO_ESP;
286
287 /*
288 * Populate the data part
289 */
290 data->cipher_algo = decap->cipher_algo;
291
292 data->esp_icv_len = decap->esp_icv_len;
293 data->esp_seq_skip = (decap->esp_seq_skip == 1);
294 data->esp_tail_skip = (decap->esp_tail_skip == 1);
295 data->auth_algo = decap->auth_algo;
296
297 data->crypto_index = decap->crypto_index;
298
299 data->nat_t_req = decap->nat_t_req;
300 if (data->nat_t_req) {
301 sel->dst_port = NSS_IPSECMGR_NATT_PORT_DATA;
302 }
303
304 data->window_size = decap->window_size;
305}
306
307/*
308 * nss_ipsecmgr_copy_encap_del()
309 * prepare the IPsec message for encap del operation
310 */
311static void nss_ipsecmgr_copy_encap_del(struct net_device *dev, struct nss_ipsec_rule *msg, union nss_ipsecmgr_rule *rule)
312{
313 struct nss_ipsecmgr_encap_del *encap = &rule->encap_del;
314 struct nss_ipsec_rule_sel *sel = &msg->sel;
315
316 /*
317 * Populate the selectors for encap direction
318 */
319 sel->ipv4_src = encap->inner_ipv4_src;
320 sel->ipv4_dst = encap->inner_ipv4_dst;
321
322 sel->src_port = encap->inner_src_port;
323 sel->dst_port = encap->inner_dst_port;
324
325 sel->ipv4_proto = encap->inner_ipv4_proto;
326}
327
328/*
329 * nss_ipsecmgr_copy_decap_del()
330 * prepare the IPsec message for decap del operation
331 */
332static void nss_ipsecmgr_copy_decap_del(struct net_device *dev, struct nss_ipsec_rule *msg, union nss_ipsecmgr_rule *rule)
333{
334 struct nss_ipsecmgr_decap_del *decap = &rule->decap_del;
335 struct nss_ipsec_rule_sel *sel = &msg->sel;
336 /*
337 * Populate the selectors for encap direction
338 */
339 sel->ipv4_src = decap->outer_ipv4_src;
340 sel->ipv4_dst = decap->outer_ipv4_dst;
341
342 sel->esp_spi = decap->esp_spi;
343
344 sel->ipv4_proto = IPPROTO_ESP;
345}
346
347/*
348 **********************
349 * message handlers
350 **********************
351 */
352/*
353 * nss_ipsecmgr_verify_add()
354 * verify the Add operation before committing
355 */
356static bool nss_ipsecmgr_verify_add(struct net_device *dev, struct nss_ipsecmgr_tbl *tbl, struct nss_ipsec_msg *nim)
357{
358 struct nss_ipsec_rule *rule = &nim->msg.push;
359 struct nss_ipsecmgr_tbl_entry *entry;
360 uint32_t tbl_idx;
Tushar Mathur26e87f12015-02-09 23:20:10 +0530361 uint32_t sa_idx;
362
363 if (nim->cm.response != NSS_CMN_RESPONSE_ACK) {
364 return false;
365 }
Sundarajan Srinivasan1b03fe22014-12-02 13:20:56 -0800366
367 tbl_idx = rule->rule_idx;
368 if (tbl_idx >= NSS_IPSEC_MAX_RULES) {
369 nss_ipsecmgr_error("table index out of range\n");
370 return false;
371 }
372
373 entry = &tbl->entry[tbl_idx];
374
375 /*
376 * XXX:Duplicate hit or hash collision; We need to handle
377 * hash collision
378 */
379 if (entry->state == NSS_IPSECMGR_ENTRY_STATE_VALID) {
380 return false;
381 }
382
383 /*
384 * Table full, XXX:must increment stats
385 */
386 if ((tbl->count + 1) >= NSS_IPSEC_MAX_RULES) {
387 return false;
388 }
389
Tushar Mathur26e87f12015-02-09 23:20:10 +0530390 sa_idx = rule->sa_idx;
391 if (sa_idx >= NSS_IPSEC_MAX_SA) {
392 nss_ipsecmgr_error("unable to add the sa_idx:%d\n", sa_idx);
393 return false;
394 }
395
Sundarajan Srinivasan1b03fe22014-12-02 13:20:56 -0800396 return true;
397}
398
399/*
400 * nss_ipsecmgr_commit_add()
401 * commit the Add operation
402 */
403static bool nss_ipsecmgr_commit_add(struct net_device *dev, struct nss_ipsecmgr_tbl *tbl, struct nss_ipsec_msg *nim)
404{
405 struct nss_ipsec_rule *rule = &nim->msg.push;
406 struct nss_ipsecmgr_tbl_entry *entry;
407 struct nss_ipsecmgr_priv *priv;
408 struct nss_ipsec_sa *sa;
409 uint32_t tbl_idx;
410 uint32_t sa_idx;
411
412 priv = netdev_priv(dev);
413
414 /* Reduce the number of availabe SA(s) as we have successfully added one */
415 atomic_dec(&gbl_drv_ctx.sa_count);
416
417 tbl_idx = rule->rule_idx;
418 entry = &tbl->entry[tbl_idx];
419
420 tbl->count++;
421
422 memcpy(&entry->sel, &rule->sel, sizeof(struct nss_ipsec_rule_sel));
423 entry->state = NSS_IPSECMGR_ENTRY_STATE_VALID;
424
425 /* increment SA use count */
426 sa_idx = rule->sa_idx;
427 sa = nss_ipsecmgr_sa_get(priv->sa_tbl, sa_idx);
428
429 /* copy rule data to SA */
430 memcpy(&sa->data, &rule->data, sizeof(struct nss_ipsec_rule_data));
431
432 /* save rule type (encap/decap) */
433 sa->type = nss_ipsecmgr_get_type(nim->cm.interface);
434
435 /* save ESP SPI in SA */
436 switch (nim->cm.interface) {
437 case NSS_IPSEC_ENCAP_IF_NUMBER:
438 sa->esp_spi = rule->oip.esp_spi;
439 break;
440
441 case NSS_IPSEC_DECAP_IF_NUMBER:
442 sa->esp_spi = rule->sel.esp_spi;
443 break;
444
445 default:
446 nss_ipsecmgr_error("invalid interface num = %d\n", nim->cm.interface);
447 return false;
448 }
449
450 /* save SA table index for this rule entry */
451 entry->sa_idx = sa_idx;
452
453 return true;
454}
455
456/*
457 * nss_ipsecmgr_verify_del()
458 * verify the del operation before committing
459 */
460static bool nss_ipsecmgr_verify_del(struct net_device *dev, struct nss_ipsecmgr_tbl *tbl, struct nss_ipsec_msg *nim)
461{
462 struct nss_ipsec_rule *rule = &nim->msg.push;
463 struct nss_ipsecmgr_tbl_entry *entry;
464 uint32_t tbl_idx;
Tushar Mathur26e87f12015-02-09 23:20:10 +0530465 uint32_t sa_idx;
466
467 if (nim->cm.response != NSS_CMN_RESPONSE_ACK) {
468 return false;
469 }
Sundarajan Srinivasan1b03fe22014-12-02 13:20:56 -0800470
471 tbl_idx = rule->rule_idx;
472 if (tbl_idx >= NSS_IPSEC_MAX_RULES) {
473 nss_ipsecmgr_error("table index out of range\n");
474 return false;
475 }
476
477 entry = &tbl->entry[tbl_idx];
478
479 /*
480 * Entry already deleted, XXX:must increment stats
481 */
482 if (entry->state == NSS_IPSECMGR_ENTRY_STATE_INVALID) {
483 return false;
484 }
485
486 /*
487 * Entry never existed, XXX:must increment stats
488 */
489 if (entry->state == NSS_IPSECMGR_ENTRY_STATE_INIT) {
490 return false;
491 }
492
493 /*
494 * Table empty, XXX:must increment stats
495 */
496 if (tbl->count == 0) {
497 return false;
498 }
499
Tushar Mathur26e87f12015-02-09 23:20:10 +0530500 sa_idx = rule->sa_idx;
501 if (sa_idx >= NSS_IPSEC_MAX_SA) {
502 nss_ipsecmgr_error("unable to delete the sa_idx:%d\n", sa_idx);
503 return false;
504 }
505
506
Sundarajan Srinivasan1b03fe22014-12-02 13:20:56 -0800507 return true;
508}
509
510/*
511 * nss_ipsecmgr_commit_del()
512 * commit the Del operation
513 */
514static bool nss_ipsecmgr_commit_del(struct net_device *dev, struct nss_ipsecmgr_tbl *tbl, struct nss_ipsec_msg *nim)
515{
516 struct nss_ipsec_rule *rule = &nim->msg.push;
517 struct nss_ipsecmgr_tbl_entry *entry;
518 struct nss_ipsecmgr_priv *priv;
519 uint32_t tbl_idx;
520 uint32_t sa_idx;
521
522 priv = netdev_priv(dev);
523
524 /* Increase the number of available SA(s) as we have successfully freed one */
525 atomic_inc(&gbl_drv_ctx.sa_count);
526
527 tbl_idx = rule->rule_idx;
528 entry = &tbl->entry[tbl_idx];
529
530 tbl->count--;
531
532 memset(&entry->sel, 0, sizeof(struct nss_ipsec_rule_sel));
533 entry->state = NSS_IPSECMGR_ENTRY_STATE_INVALID;
534
535 /* decrement SA use count */
536 sa_idx = rule->sa_idx;
537 nss_ipsecmgr_sa_put(priv->sa_tbl, sa_idx);
538
539 return true;
540}
541
542/*
543 * nss_ipsecmgr_verify_stats()
544 * verify stats update operation
545 */
546static bool nss_ipsecmgr_verify_stats(struct net_device *dev, struct nss_ipsecmgr_tbl *tbl, struct nss_ipsec_msg *nim)
547{
Tushar Mathur26e87f12015-02-09 23:20:10 +0530548 struct nss_ipsec_sa_stats *msg_stats = &nim->msg.stats;
Sundarajan Srinivasan1b03fe22014-12-02 13:20:56 -0800549
550 /*
551 * Table empty, nothing to update
552 */
553 if (tbl->count == 0) {
554 return false;
555 }
556
Tushar Mathur26e87f12015-02-09 23:20:10 +0530557 if (msg_stats->sa_idx >= NSS_CRYPTO_MAX_IDXS) {
Sundarajan Srinivasan1b03fe22014-12-02 13:20:56 -0800558 return false;
559 }
560
561 return true;
562}
563
564/*
565 * nss_ipsecmgr_commit_stats()
566 * commit stats for the SA
567 */
568static bool nss_ipsecmgr_commit_stats(struct net_device *dev, struct nss_ipsecmgr_tbl *tbl, struct nss_ipsec_msg *nim)
569{
570 struct nss_ipsec_sa_stats *msg_stats = &nim->msg.stats;
571 struct nss_ipsec_sa_stats *sa_stats;
572 struct nss_ipsec_sa *sa;
573 struct nss_ipsecmgr_priv *priv;
574 struct nss_ipsecmgr_event event = {.type = NSS_IPSECMGR_EVENT_SA_STATS};
575 struct nss_ipsecmgr_sa_stats *event_stats = &event.data.stats;
576 nss_ipsecmgr_event_cb_t event_cb;
577 void *cb_ctx;
578 uint32_t sa_idx;
579
580 priv = netdev_priv(dev);
581
582 /* get reference to SA stats */
583 sa_idx = msg_stats->sa_idx;
584 sa = nss_ipsecmgr_sa_get(priv->sa_tbl, sa_idx);
585
586 sa_stats = &sa->stats;
587
588 /* copy SA statistics */
589 sa_stats->seqnum = msg_stats->seqnum;
590 memcpy(&sa_stats->pkts, &msg_stats->pkts, sizeof(struct nss_ipsec_pkt_stats));
591
592 /* execute event callback to send SA stats event */
593 event_cb = priv->event_cb;
594 cb_ctx = priv->cb_ctx;
595 if (event_cb && cb_ctx) {
596 event_stats->esp_spi = sa->esp_spi;
597 event_stats->seqnum = sa_stats->seqnum;
598 event_stats->crypto_index = sa->data.crypto_index;
599 event_stats->type = sa->type;
600
601 event_stats->pkts_processed = sa_stats->pkts.processed;
602 event_stats->pkts_dropped = sa_stats->pkts.dropped;
603 event_stats->pkts_failed = sa_stats->pkts.failed;
604
605 event_cb(cb_ctx, &event);
606 }
607
608 /* decrement SA use count */
609 nss_ipsecmgr_sa_put(priv->sa_tbl, sa_idx);
610
611 return true;
612}
613
614/*
615 * nss_ipsecmgr_verify_flush()
616 * verify the flush operation
617 */
618static bool nss_ipsecmgr_verify_flush(struct net_device *dev, struct nss_ipsecmgr_tbl *tbl, struct nss_ipsec_msg *nim)
619{
620 return true;
621}
622
623/*
624 * nss_ipsecmgr_commit_flush()
625 * commit the flush operation
626 */
627static bool nss_ipsecmgr_commit_flush(struct net_device *dev, struct nss_ipsecmgr_tbl *tbl, struct nss_ipsec_msg *nim)
628{
629 struct nss_ipsecmgr_priv *priv;
630 struct nss_ipsec_sa *sa;
631 int32_t count;
632
633 priv = netdev_priv(dev);
634
635 tbl->count = 0;
636
637 for (count = 0, sa = &priv->sa_tbl[0]; count < NSS_IPSEC_MAX_SA; count++, sa++) {
638 nss_ipsecmgr_sa_init(sa);
639 }
640
641 return true;
642}
643
644/*
645 * callback operation
646 */
647const static struct nss_ipsecmgr_ops cb_ops[NSS_IPSEC_MSG_TYPE_MAX] = {
648 [NSS_IPSEC_MSG_TYPE_ADD_RULE] = {nss_ipsecmgr_verify_add, nss_ipsecmgr_commit_add},
649 [NSS_IPSEC_MSG_TYPE_DEL_RULE] = {nss_ipsecmgr_verify_del, nss_ipsecmgr_commit_del},
650 [NSS_IPSEC_MSG_TYPE_SYNC_STATS] = {nss_ipsecmgr_verify_stats, nss_ipsecmgr_commit_stats},
651 [NSS_IPSEC_MSG_TYPE_FLUSH_TUN] = {nss_ipsecmgr_verify_flush, nss_ipsecmgr_commit_flush}
652};
653
654/*
655 * nss_ipsecmgr_op_receive()
656 * asynchronous event reception
657 */
658static void nss_ipsecmgr_op_receive(void *app_data, struct nss_ipsec_msg *nim)
659{
660 struct net_device *tun_dev = (struct net_device *)app_data;
661 struct nss_ipsecmgr_priv *priv;
662 struct nss_ipsecmgr_tbl *tbl;
663 nss_ipsecmgr_op_t verify_fn;
664 nss_ipsecmgr_op_t commit_fn;
665 struct net_device *dev;
666
667 BUG_ON(tun_dev == NULL);
668 BUG_ON(nim == NULL);
669
670 /* this holds the ref_cnt for the device */
671 dev = dev_get_by_index(&init_net, nim->tunnel_id);
672 if (dev == NULL) {
673 nss_ipsecmgr_error("event received on deallocated I/F (%d)\n", nim->tunnel_id);
674 return;
675 }
676
677 if (dev != tun_dev) {
678 nss_ipsecmgr_error("event received on incorrect I/F (%d)\n", nim->tunnel_id);
679 goto done;
680 }
681
682 priv = netdev_priv(dev);
683
684 tbl = nss_ipsecmgr_get_tbl(priv, nim->cm.interface);
685 if (tbl == NULL) {
686 nss_ipsecmgr_error("invalid interface number(%d)\n", nim->cm.interface);
687 goto done;
688 }
689
690 verify_fn = cb_ops[nim->cm.type].verify_fn;
691 commit_fn = cb_ops[nim->cm.type].commit_fn;
692
693 if (!verify_fn || !commit_fn) {
694 nss_ipsecmgr_error("unhandled type (%d)\n", nim->cm.type);
695 goto done;
696 }
697
698 /*
699 * Now we can operate on the entry of the table
700 */
701 spin_lock_bh(&tbl->lock);
702
703 if (verify_fn(dev, tbl, nim) == true) {
704 commit_fn(dev, tbl, nim);
705 }
706
707 spin_unlock_bh(&tbl->lock);
708done:
709 /* release the device as we are done */
710 dev_put(dev);
711}
712
713/*
714 * nss_ipsecmgr_op_send()
715 * Push a IPsec rule to NSS
716 */
717static bool nss_ipsecmgr_op_send(struct net_device *dev, struct nss_ipsec_msg *nim, uint32_t if_num, enum nss_ipsec_msg_type type)
718{
719 struct nss_ipsecmgr_priv *priv;
720 nss_tx_status_t status;
721
722 priv = netdev_priv(dev);
723 if (priv->nss_ctx == NULL) {
724 nss_ipsecmgr_error("Tunnel registration or de-registration is underway\n");
725 return false;
726 }
727
728 nim->tunnel_id = dev->ifindex;
729
730 nss_ipsec_msg_init(nim, if_num, type, NSS_IPSEC_MSG_LEN, (nss_ipsec_msg_callback_t *)nss_ipsecmgr_op_receive, dev);
731
732 status = nss_ipsec_tx_msg(priv->nss_ctx, nim);
733 if (status != NSS_TX_SUCCESS) {
734 nss_ipsecmgr_error("unable to push rule(%d) for %s\n", type, dev->name);
735 return false;
736 }
737
738 return true;
739}
740
741/*
742 * nss_ipsecmgr_buf_receive()
743 * receive NSS exception packets
744 */
745static void nss_ipsecmgr_buf_receive(struct net_device *dev, struct sk_buff *skb, __attribute((unused)) struct napi_struct *napi)
746{
747 struct nss_ipsecmgr_priv *priv;
748 nss_ipsecmgr_data_cb_t cb_fn;
749 void *cb_ctx;
750 struct iphdr *ip;
751
752 BUG_ON(dev == NULL);
753 BUG_ON(skb == NULL);
754
755 /* hold the device till we process it */
756 dev_hold(dev);
757
758 /*
759 * XXX:need to ensure that the dev being accessed is not deleted
760 */
761 priv = netdev_priv(dev);
762
763 skb->dev = dev;
764
765 cb_fn = priv->data_cb;
766 cb_ctx = priv->cb_ctx;
767
768 /*
769 * if tunnel creator gave a callback then send the packet without
770 * any modifications to him
771 */
772 if (cb_fn && cb_ctx) {
773 cb_fn(cb_ctx, skb);
774 goto done;
775 }
776
777 ip = (struct iphdr *)skb->data;
778 if ((ip->version != IPVERSION) || (ip->ihl != 5)) {
779 nss_ipsecmgr_error("dropping packets(IP version:%x, Header len:%x)\n", ip->version, ip->ihl);
780 dev_kfree_skb_any(skb);
781 goto done;
782 }
783
784 skb_reset_network_header(skb);
785 skb_reset_mac_header(skb);
786
787 skb->pkt_type = PACKET_HOST;
788 skb->protocol = cpu_to_be16(ETH_P_IP);
789 skb->skb_iif = dev->ifindex;
790
791 netif_receive_skb(skb);
792done:
793 /* release the device as we are done */
794 dev_put(dev);
795}
796
797/*
798 **********************
799 * Netdev ops
800 **********************
801 */
802
803/*
804 * nss_ipsecmgr_tunnel_init()
805 * initiallizes the tunnel
806 */
807static int nss_ipsecmgr_tunnel_init(struct net_device *dev)
808{
809 struct nss_ipsecmgr_priv *priv;
810
811 priv = netdev_priv(dev);
812
813 priv->nss_ctx = nss_ipsec_get_context();
814
815 return 0;
816}
817
818/*
819 * nss_ipsecmgr_tunnel_exit()
820 * deinitiallizes the tunnel
821 */
822static void nss_ipsecmgr_tunnel_exit(struct net_device *dev)
823{
824 struct nss_ipsecmgr_priv *priv;
825
826 priv = netdev_priv(dev);
827
828 priv->nss_ctx = NULL;
829}
830
831/*
832 * nss_ipsecmgr_tunnel_open()
833 * open the tunnel for usage
834 */
835static int nss_ipsecmgr_tunnel_open(struct net_device *dev)
836{
837 struct nss_ipsecmgr_priv *priv;
838
839 priv = netdev_priv(dev);
840
841 netif_start_queue(dev);
842
843 return 0;
844}
845
846/*
847 * nss_ipsecmgr_tunnel_stop()
848 * stop the IPsec tunnel
849 */
850static int nss_ipsecmgr_tunnel_stop(struct net_device *dev)
851{
852 struct nss_ipsecmgr_priv *priv;
853
854 priv = netdev_priv(dev);
855
856 netif_stop_queue(dev);
857
858 return 0;
859}
860
861/*
862 * nss_ipsecmgr_tunnel_xmit()
863 * tunnel transmit function
864 */
865static netdev_tx_t nss_ipsecmgr_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
866{
867 uint32_t if_num;
868 struct iphdr *inner_ip;
869 struct nss_ipsecmgr_priv *priv;
870 struct nss_ipsecmgr_tbl *encap;
871
872 if_num = NSS_IPSEC_ENCAP_IF_NUMBER;
873 priv = netdev_priv(dev);
874 encap = &priv->encap;
875
876 if (skb_is_nonlinear(skb)) {
877 nss_ipsecmgr_error("%p: NSS IPSEC does not support fragments %p\n", priv->nss_ctx, skb);
878 goto fail;
879 }
880
881 /*
882 * Check if skb is shared
883 */
884 if (unlikely(skb_shared(skb))) {
885 nss_ipsecmgr_error("%p: Shared skb is not supported: %p\n", priv->nss_ctx, skb);
886 goto fail;
887 }
888
889 /*
890 * Check the packet head room & tail room
891 */
892 if (unlikely(skb_headroom(skb) < dev->needed_headroom)) {
893 nss_ipsecmgr_error("%p: Insufficient head room :%d in skb: %p\n", priv->nss_ctx, skb_headroom(skb), skb);
894 goto fail;
895 }
896
897 if (unlikely(skb_tailroom(skb) < dev->needed_tailroom)) {
898 nss_ipsecmgr_error("%p: Insufficient tail room:%d in skb: %p\n", priv->nss_ctx, skb_tailroom(skb), skb);
899 goto fail;
900 }
901
902 /*
903 * Check if packet is given starting from network header
904 */
905 if (skb->data != skb_network_header(skb)) {
906 nss_ipsecmgr_error("%p: 'Skb data is not starting from IP header", priv->nss_ctx);
907 goto fail;
908 }
909
910 inner_ip = (struct iphdr *)ip_hdr(skb);
911
912 /*
913 * Validate if packet has ip options
914 */
915 if ((inner_ip->version != IPVERSION) || (inner_ip->ihl != 5)) {
916 nss_ipsecmgr_error("%p: Unsupported IP header ipver: 0x%x iphdr_len: 0x%x\n", priv->nss_ctx,
917 inner_ip->version, inner_ip->ihl);
918 goto fail;
919 }
920
921 /*
922 * Check the TTL value
923 */
924 if ((inner_ip->ttl == 0)) {
925 nss_ipsecmgr_error("%p: IP TTL is zero, unabled to transmit\n", priv->nss_ctx);
926 goto fail;
927 }
928
929 /*
930 * Send the packet down
931 */
932 if (nss_ipsec_tx_buf(skb, if_num) != 0) {
933 /*
934 * TODO: NEED TO STOP THE QUEUE
935 */
936 goto fail;
937 }
938
939 /*
940 * Increment the tx count
941 */
942 encap->total_tx++;
943
944 return NETDEV_TX_OK;
945
946fail:
947 return NETDEV_TX_BUSY;
948}
949
950/*
951 * nss_ipsecmgr_tunnel_stats()
952 * get tunnel statistics
953 */
954static struct net_device_stats *nss_ipsecmgr_tunnel_stats(struct net_device *dev)
955{
956 struct net_device_stats *stats = &dev->stats;
957 struct nss_ipsecmgr_priv *priv;
958 struct nss_ipsec_sa *sa;
959 uint32_t i;
960
961 memset(stats, 0, sizeof(struct net_device_stats));
962
963 priv = netdev_priv(dev);
964
965 for (i = 0, sa = &priv->sa_tbl[0]; i < NSS_IPSEC_MAX_SA; i++, sa++) {
966 if (atomic_read(&sa->user) == 0) {
967 continue;
968 }
969
970 switch (sa->type) {
971 case NSS_IPSECMGR_RULE_TYPE_ENCAP:
972 stats->tx_packets += sa->stats.pkts.processed;
973 stats->tx_dropped += sa->stats.pkts.dropped;
974 break;
975
976 case NSS_IPSECMGR_RULE_TYPE_DECAP:
977 stats->rx_packets += sa->stats.pkts.processed;
978 stats->rx_dropped += sa->stats.pkts.dropped;
979 break;
980
981 default:
982 nss_ipsecmgr_error("unknown ipsec rule type\n");
983 break;
984 }
985 }
986
987 return stats;
988}
989
990/* NSS IPsec tunnel operation */
991static const struct net_device_ops nss_ipsecmgr_tunnel_ops = {
992 .ndo_init = nss_ipsecmgr_tunnel_init,
993 .ndo_uninit = nss_ipsecmgr_tunnel_exit,
994 .ndo_start_xmit = nss_ipsecmgr_tunnel_xmit,
995 .ndo_open = nss_ipsecmgr_tunnel_open,
996 .ndo_stop = nss_ipsecmgr_tunnel_stop,
997 .ndo_get_stats = nss_ipsecmgr_tunnel_stats,
998};
999
1000/*
1001 * nss_ipsecmgr_tunnel_free()
1002 * free an existing IPsec tunnel interface
1003 */
1004static void nss_ipsecmgr_tunnel_free(struct net_device *dev)
1005{
1006 struct nss_ipsecmgr_priv *priv = netdev_priv(dev);
1007 struct nss_ipsecmgr_tbl *encap_tbl;
1008 struct nss_ipsecmgr_tbl *decap_tbl;
1009
1010 encap_tbl = &priv->encap;
1011 decap_tbl = &priv->decap;
1012
1013 nss_ipsecmgr_info("IPsec tunnel device(%s) freed\n", dev->name);
1014 nss_ipsecmgr_info("Entries left: encap(%d), decap(%d)\n", encap_tbl->count, decap_tbl->count);
1015
1016 free_netdev(dev);
1017}
1018
1019/*
1020 * nss_ipsecmr_setup_tunnel()
1021 * setup the IPsec tunnel
1022 */
1023static void nss_ipsecmgr_tunnel_setup(struct net_device *dev)
1024{
1025 dev->addr_len = ETH_ALEN;
1026 dev->mtu = NSS_IPSECMGR_TUN_MTU(ETH_DATA_LEN);
1027
1028 dev->hard_header_len = NSS_IPSECMGR_TUN_MAX_HDR_LEN;
1029 dev->needed_headroom = NSS_IPSECMGR_TUN_HEADROOM;
1030 dev->needed_tailroom = NSS_IPSECMGR_TUN_TAILROOM;
1031
1032 dev->type = NSS_IPSEC_ARPHRD_IPSEC;
1033
1034 dev->ethtool_ops = NULL;
1035 dev->header_ops = NULL;
1036 dev->netdev_ops = &nss_ipsecmgr_tunnel_ops;
1037
1038 dev->destructor = nss_ipsecmgr_tunnel_free;
1039
1040 /*
1041 * XXX:should get the MAC address from the ethernet device
1042 */
1043 memcpy(dev->dev_addr, "\xaa\xbb\xcc\xdd\xee\xff", dev->addr_len);
1044 memset(dev->broadcast, 0xff, dev->addr_len);
1045 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
1046}
1047
1048/*
1049 **********************
1050 * Exported Functions
1051 **********************
1052 */
1053
1054/*
1055 * nss_ipsecmgr_tunnel_add()
1056 * add a IPsec pseudo tunnel device
1057 */
1058struct net_device *nss_ipsecmgr_tunnel_add(void *cb_ctx, nss_ipsecmgr_data_cb_t data_cb, nss_ipsecmgr_event_cb_t event_cb)
1059{
1060 struct net_device *dev;
1061 struct nss_ipsecmgr_priv *priv;
1062 struct nss_ipsec_sa *sa;
1063 int status;
1064 int count;
1065 int32_t if_num;
1066
1067 /* Features denote the skb types supported */
1068 uint32_t features = 0;
1069
1070 dev = alloc_netdev(sizeof(struct nss_ipsecmgr_priv), NSS_IPSECMGR_TUN_NAME, nss_ipsecmgr_tunnel_setup);
1071 if (!dev) {
1072 nss_ipsecmgr_error("unable to allocate a tunnel device\n");
1073 return NULL;
1074 }
1075
1076 priv = netdev_priv(dev);
1077
1078 priv->cb_ctx = cb_ctx;
1079 priv->data_cb = data_cb;
1080 priv->event_cb = event_cb;
1081
1082 /* initialize SA stats table for this tunnel */
1083 for (count = 0, sa = &priv->sa_tbl[0]; count < NSS_IPSEC_MAX_SA; count++, sa++) {
1084 nss_ipsecmgr_sa_init(sa);
1085 }
1086
1087 spin_lock_init(&priv->encap.lock);
1088 spin_lock_init(&priv->decap.lock);
1089
1090 status = rtnl_is_locked() ? register_netdevice(dev) : register_netdev(dev);
1091 if (status < 0) {
1092 goto fail;
1093 }
1094
1095 if_num = nss_ipsec_get_interface(priv->nss_ctx);
1096 if (if_num < 0) {
1097 nss_ipsecmgr_error("Invalid nss interface :%d\n", if_num);
1098 return NULL;
1099 }
1100
1101 nss_ipsec_data_register(if_num, nss_ipsecmgr_buf_receive, dev, features);
1102
1103 /*
1104 * Store data interface number in private data
1105 */
1106 priv->nss_ifnum = if_num;
1107
1108 nss_ipsec_notify_register(NSS_IPSEC_ENCAP_IF_NUMBER, nss_ipsecmgr_op_receive, dev);
1109 nss_ipsec_notify_register(NSS_IPSEC_DECAP_IF_NUMBER, nss_ipsecmgr_op_receive, dev);
1110
1111 return dev;
1112
1113fail:
1114 free_netdev(dev);
1115
1116 return NULL;
1117}
1118EXPORT_SYMBOL(nss_ipsecmgr_tunnel_add);
1119
1120/*
1121 * nss_ipsecmgr_del_tunnel()
1122 * delete an existing IPsec tunnel
1123 */
1124bool nss_ipsecmgr_tunnel_del(struct net_device *dev)
1125{
1126 struct nss_ipsecmgr_priv *priv;
1127 struct nss_ipsecmgr_tbl *encap;
1128 struct nss_ipsecmgr_tbl *decap;
1129 struct nss_ipsec_msg nim;
1130 bool status;
1131
1132 priv = netdev_priv(dev);
1133
1134 encap = &priv->encap;
1135 decap = &priv->decap;
1136
1137 /*
1138 * Unregister the callbacks from the HLOS as we are no longer
1139 * interested in exception data & async messages
1140 */
1141 nss_ipsec_data_unregister(priv->nss_ctx, priv->nss_ifnum);
1142
1143 nss_ipsec_notify_unregister(priv->nss_ctx, NSS_IPSEC_ENCAP_IF_NUMBER);
1144 nss_ipsec_notify_unregister(priv->nss_ctx, NSS_IPSEC_DECAP_IF_NUMBER);
1145
1146 priv->data_cb = NULL;
1147 priv->event_cb = NULL;
1148
1149 /*
1150 * Prepare to flush all SA(s) inside a tunnel
1151 */
1152 memset(&nim, 0, sizeof(struct nss_ipsec_msg));
1153
1154 status = nss_ipsecmgr_op_send(dev, &nim, NSS_IPSEC_ENCAP_IF_NUMBER, NSS_IPSEC_MSG_TYPE_FLUSH_TUN);
1155 if (status != true) {
1156 nss_ipsecmgr_error("unable complete tunnel deletion, for ingress rules\n");
1157 goto fail;
1158 }
1159
1160 /* release all SA(s) associated with the encap */
1161 atomic_sub(encap->count, &gbl_drv_ctx.sa_count);
1162
1163 status = nss_ipsecmgr_op_send(dev, &nim, NSS_IPSEC_DECAP_IF_NUMBER, NSS_IPSEC_MSG_TYPE_FLUSH_TUN);
1164 if (status != true) {
1165 nss_ipsecmgr_error("unable complete tunnel deletion, for egress rules\n");
1166 goto fail;
1167 }
1168
1169 /* release all SA(s) associated with the decap */
1170 atomic_sub(decap->count, &gbl_drv_ctx.sa_count);
1171
1172 /*
1173 * The unregister should start here but the expectation is that the free would
1174 * happen when the reference count goes down to '0'
1175 */
1176 rtnl_is_locked() ? unregister_netdevice(dev) : unregister_netdev(dev);
1177
1178 return true;
1179fail:
1180 /* caller must retry */
1181 return false;
1182}
1183EXPORT_SYMBOL(nss_ipsecmgr_tunnel_del);
1184
1185/*
1186 * nss_ipsecmgr_sa_add()
1187 * add a new SA to the tunnel
1188 */
1189bool nss_ipsecmgr_sa_add(struct net_device *dev, union nss_ipsecmgr_rule *rule, enum nss_ipsecmgr_rule_type type)
1190{
1191 struct nss_ipsecmgr_priv *priv;
1192 struct nss_ipsec_msg nim;
1193 uint32_t if_num;
1194
1195 priv = netdev_priv(dev);
1196
1197 /* check if there are free SA(s) */
1198 if (atomic_read(&gbl_drv_ctx.sa_count) == 0) {
1199 return false;
1200 }
1201
1202 memset(&nim, 0, sizeof(struct nss_ipsec_msg));
1203
1204 /* XXX: some basic validation of the passed rule needs to happen */
1205
1206 switch (type) {
1207 case NSS_IPSECMGR_RULE_TYPE_ENCAP:
1208 if_num = NSS_IPSEC_ENCAP_IF_NUMBER;
1209 nss_ipsecmgr_copy_encap_add(dev, &nim.msg.push, rule);
1210 break;
1211
1212 case NSS_IPSECMGR_RULE_TYPE_DECAP:
1213 if_num = NSS_IPSEC_DECAP_IF_NUMBER;
1214 nss_ipsecmgr_copy_decap_add(dev, &nim.msg.push, rule);
1215 break;
1216
1217 default:
1218 nss_ipsecmgr_error("Unknown rule type(%d) for Add operation\n", type);
1219 return false;
1220 }
1221
1222 return nss_ipsecmgr_op_send(dev, &nim, if_num, NSS_IPSEC_MSG_TYPE_ADD_RULE);
1223
1224}
1225EXPORT_SYMBOL(nss_ipsecmgr_sa_add);
1226
1227/*
1228 * nss_ipsecmgr_sa_del()
1229 *
1230 */
1231bool nss_ipsecmgr_sa_del(struct net_device *dev, union nss_ipsecmgr_rule *rule, enum nss_ipsecmgr_rule_type type)
1232{
1233 struct nss_ipsecmgr_priv *priv;
1234 struct nss_ipsec_msg nim;
1235 uint32_t if_num;
1236
1237 priv = netdev_priv(dev);
1238
1239 /* check if all SA(s) are already freed */
1240 if (atomic_read(&gbl_drv_ctx.sa_count) == NSS_IPSEC_MAX_RULES) {
1241 return false;
1242 }
1243
1244 memset(&nim, 0, sizeof(struct nss_ipsec_msg));
1245
1246 /* XXX: some basic validation of the passed rule needs to happen */
1247
1248 switch (type) {
1249 case NSS_IPSECMGR_RULE_TYPE_ENCAP:
1250 if_num = NSS_IPSEC_ENCAP_IF_NUMBER;
1251 nss_ipsecmgr_copy_encap_del(dev, &nim.msg.push, rule);
1252 break;
1253
1254 case NSS_IPSECMGR_RULE_TYPE_DECAP:
1255 if_num = NSS_IPSEC_DECAP_IF_NUMBER;
1256 nss_ipsecmgr_copy_decap_del(dev, &nim.msg.push, rule);
1257 break;
1258
1259 default:
1260 nss_ipsecmgr_error("Unknown rule type(%d) for Del operation\n", type);
1261 return false;
1262 }
1263 return nss_ipsecmgr_op_send(dev, &nim, if_num, NSS_IPSEC_MSG_TYPE_DEL_RULE);
1264}
1265EXPORT_SYMBOL(nss_ipsecmgr_sa_del);
1266
1267static int __init nss_ipsecmgr_init(void)
1268{
1269 nss_ipsecmgr_info("NSS IPsec manager loaded: Build date %s\n", __DATE__);
1270
1271 memset(&gbl_drv_ctx, 0, sizeof(struct nss_ipsecmgr_drv));
1272
1273 atomic_set(&gbl_drv_ctx.sa_count, NSS_IPSEC_MAX_RULES);
1274
1275 return 0;
1276}
1277
1278
1279static void __exit nss_ipsecmgr_exit(void)
1280{
1281 nss_ipsecmgr_info("NSS IPsec manager unloader\n");
1282}
1283
1284module_init(nss_ipsecmgr_init);
1285module_exit(nss_ipsecmgr_exit);