act_csum.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. /*
  2. * Checksum updating actions
  3. *
  4. * Copyright (c) 2010 Gregoire Baron <baronchon@n7mm.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation; either version 2 of the License, or (at your option)
  9. * any later version.
  10. *
  11. */
  12. #include <linux/types.h>
  13. #include <linux/init.h>
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/spinlock.h>
  17. #include <linux/netlink.h>
  18. #include <net/netlink.h>
  19. #include <linux/rtnetlink.h>
  20. #include <linux/skbuff.h>
  21. #include <net/ip.h>
  22. #include <net/ipv6.h>
  23. #include <net/icmp.h>
  24. #include <linux/icmpv6.h>
  25. #include <linux/igmp.h>
  26. #include <net/tcp.h>
  27. #include <net/udp.h>
  28. #include <net/ip6_checksum.h>
  29. #include <net/sctp/checksum.h>
  30. #include <net/act_api.h>
  31. #include <linux/tc_act/tc_csum.h>
  32. #include <net/tc_act/tc_csum.h>
  33. #define CSUM_TAB_MASK 15
  34. static const struct nla_policy csum_policy[TCA_CSUM_MAX + 1] = {
  35. [TCA_CSUM_PARMS] = { .len = sizeof(struct tc_csum), },
  36. };
  37. static unsigned int csum_net_id;
  38. static struct tc_action_ops act_csum_ops;
  39. static int tcf_csum_init(struct net *net, struct nlattr *nla,
  40. struct nlattr *est, struct tc_action **a, int ovr,
  41. int bind)
  42. {
  43. struct tc_action_net *tn = net_generic(net, csum_net_id);
  44. struct nlattr *tb[TCA_CSUM_MAX + 1];
  45. struct tc_csum *parm;
  46. struct tcf_csum *p;
  47. int ret = 0, err;
  48. if (nla == NULL)
  49. return -EINVAL;
  50. err = nla_parse_nested(tb, TCA_CSUM_MAX, nla, csum_policy, NULL);
  51. if (err < 0)
  52. return err;
  53. if (tb[TCA_CSUM_PARMS] == NULL)
  54. return -EINVAL;
  55. parm = nla_data(tb[TCA_CSUM_PARMS]);
  56. if (!tcf_hash_check(tn, parm->index, a, bind)) {
  57. ret = tcf_hash_create(tn, parm->index, est, a,
  58. &act_csum_ops, bind, false);
  59. if (ret)
  60. return ret;
  61. ret = ACT_P_CREATED;
  62. } else {
  63. if (bind)/* dont override defaults */
  64. return 0;
  65. tcf_hash_release(*a, bind);
  66. if (!ovr)
  67. return -EEXIST;
  68. }
  69. p = to_tcf_csum(*a);
  70. spin_lock_bh(&p->tcf_lock);
  71. p->tcf_action = parm->action;
  72. p->update_flags = parm->update_flags;
  73. spin_unlock_bh(&p->tcf_lock);
  74. if (ret == ACT_P_CREATED)
  75. tcf_hash_insert(tn, *a);
  76. return ret;
  77. }
  78. /**
  79. * tcf_csum_skb_nextlayer - Get next layer pointer
  80. * @skb: sk_buff to use
  81. * @ihl: previous summed headers length
  82. * @ipl: complete packet length
  83. * @jhl: next header length
  84. *
  85. * Check the expected next layer availability in the specified sk_buff.
  86. * Return the next layer pointer if pass, NULL otherwise.
  87. */
  88. static void *tcf_csum_skb_nextlayer(struct sk_buff *skb,
  89. unsigned int ihl, unsigned int ipl,
  90. unsigned int jhl)
  91. {
  92. int ntkoff = skb_network_offset(skb);
  93. int hl = ihl + jhl;
  94. if (!pskb_may_pull(skb, ipl + ntkoff) || (ipl < hl) ||
  95. skb_try_make_writable(skb, hl + ntkoff))
  96. return NULL;
  97. else
  98. return (void *)(skb_network_header(skb) + ihl);
  99. }
  100. static int tcf_csum_ipv4_icmp(struct sk_buff *skb, unsigned int ihl,
  101. unsigned int ipl)
  102. {
  103. struct icmphdr *icmph;
  104. icmph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*icmph));
  105. if (icmph == NULL)
  106. return 0;
  107. icmph->checksum = 0;
  108. skb->csum = csum_partial(icmph, ipl - ihl, 0);
  109. icmph->checksum = csum_fold(skb->csum);
  110. skb->ip_summed = CHECKSUM_NONE;
  111. return 1;
  112. }
  113. static int tcf_csum_ipv4_igmp(struct sk_buff *skb,
  114. unsigned int ihl, unsigned int ipl)
  115. {
  116. struct igmphdr *igmph;
  117. igmph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*igmph));
  118. if (igmph == NULL)
  119. return 0;
  120. igmph->csum = 0;
  121. skb->csum = csum_partial(igmph, ipl - ihl, 0);
  122. igmph->csum = csum_fold(skb->csum);
  123. skb->ip_summed = CHECKSUM_NONE;
  124. return 1;
  125. }
  126. static int tcf_csum_ipv6_icmp(struct sk_buff *skb, unsigned int ihl,
  127. unsigned int ipl)
  128. {
  129. struct icmp6hdr *icmp6h;
  130. const struct ipv6hdr *ip6h;
  131. icmp6h = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*icmp6h));
  132. if (icmp6h == NULL)
  133. return 0;
  134. ip6h = ipv6_hdr(skb);
  135. icmp6h->icmp6_cksum = 0;
  136. skb->csum = csum_partial(icmp6h, ipl - ihl, 0);
  137. icmp6h->icmp6_cksum = csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
  138. ipl - ihl, IPPROTO_ICMPV6,
  139. skb->csum);
  140. skb->ip_summed = CHECKSUM_NONE;
  141. return 1;
  142. }
  143. static int tcf_csum_ipv4_tcp(struct sk_buff *skb, unsigned int ihl,
  144. unsigned int ipl)
  145. {
  146. struct tcphdr *tcph;
  147. const struct iphdr *iph;
  148. if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
  149. return 1;
  150. tcph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*tcph));
  151. if (tcph == NULL)
  152. return 0;
  153. iph = ip_hdr(skb);
  154. tcph->check = 0;
  155. skb->csum = csum_partial(tcph, ipl - ihl, 0);
  156. tcph->check = tcp_v4_check(ipl - ihl,
  157. iph->saddr, iph->daddr, skb->csum);
  158. skb->ip_summed = CHECKSUM_NONE;
  159. return 1;
  160. }
  161. static int tcf_csum_ipv6_tcp(struct sk_buff *skb, unsigned int ihl,
  162. unsigned int ipl)
  163. {
  164. struct tcphdr *tcph;
  165. const struct ipv6hdr *ip6h;
  166. if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
  167. return 1;
  168. tcph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*tcph));
  169. if (tcph == NULL)
  170. return 0;
  171. ip6h = ipv6_hdr(skb);
  172. tcph->check = 0;
  173. skb->csum = csum_partial(tcph, ipl - ihl, 0);
  174. tcph->check = csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
  175. ipl - ihl, IPPROTO_TCP,
  176. skb->csum);
  177. skb->ip_summed = CHECKSUM_NONE;
  178. return 1;
  179. }
  180. static int tcf_csum_ipv4_udp(struct sk_buff *skb, unsigned int ihl,
  181. unsigned int ipl, int udplite)
  182. {
  183. struct udphdr *udph;
  184. const struct iphdr *iph;
  185. u16 ul;
  186. /*
  187. * Support both UDP and UDPLITE checksum algorithms, Don't use
  188. * udph->len to get the real length without any protocol check,
  189. * UDPLITE uses udph->len for another thing,
  190. * Use iph->tot_len, or just ipl.
  191. */
  192. udph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*udph));
  193. if (udph == NULL)
  194. return 0;
  195. iph = ip_hdr(skb);
  196. ul = ntohs(udph->len);
  197. if (udplite || udph->check) {
  198. udph->check = 0;
  199. if (udplite) {
  200. if (ul == 0)
  201. skb->csum = csum_partial(udph, ipl - ihl, 0);
  202. else if ((ul >= sizeof(*udph)) && (ul <= ipl - ihl))
  203. skb->csum = csum_partial(udph, ul, 0);
  204. else
  205. goto ignore_obscure_skb;
  206. } else {
  207. if (ul != ipl - ihl)
  208. goto ignore_obscure_skb;
  209. skb->csum = csum_partial(udph, ul, 0);
  210. }
  211. udph->check = csum_tcpudp_magic(iph->saddr, iph->daddr,
  212. ul, iph->protocol,
  213. skb->csum);
  214. if (!udph->check)
  215. udph->check = CSUM_MANGLED_0;
  216. }
  217. skb->ip_summed = CHECKSUM_NONE;
  218. ignore_obscure_skb:
  219. return 1;
  220. }
  221. static int tcf_csum_ipv6_udp(struct sk_buff *skb, unsigned int ihl,
  222. unsigned int ipl, int udplite)
  223. {
  224. struct udphdr *udph;
  225. const struct ipv6hdr *ip6h;
  226. u16 ul;
  227. /*
  228. * Support both UDP and UDPLITE checksum algorithms, Don't use
  229. * udph->len to get the real length without any protocol check,
  230. * UDPLITE uses udph->len for another thing,
  231. * Use ip6h->payload_len + sizeof(*ip6h) ... , or just ipl.
  232. */
  233. udph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*udph));
  234. if (udph == NULL)
  235. return 0;
  236. ip6h = ipv6_hdr(skb);
  237. ul = ntohs(udph->len);
  238. udph->check = 0;
  239. if (udplite) {
  240. if (ul == 0)
  241. skb->csum = csum_partial(udph, ipl - ihl, 0);
  242. else if ((ul >= sizeof(*udph)) && (ul <= ipl - ihl))
  243. skb->csum = csum_partial(udph, ul, 0);
  244. else
  245. goto ignore_obscure_skb;
  246. } else {
  247. if (ul != ipl - ihl)
  248. goto ignore_obscure_skb;
  249. skb->csum = csum_partial(udph, ul, 0);
  250. }
  251. udph->check = csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, ul,
  252. udplite ? IPPROTO_UDPLITE : IPPROTO_UDP,
  253. skb->csum);
  254. if (!udph->check)
  255. udph->check = CSUM_MANGLED_0;
  256. skb->ip_summed = CHECKSUM_NONE;
  257. ignore_obscure_skb:
  258. return 1;
  259. }
  260. static int tcf_csum_sctp(struct sk_buff *skb, unsigned int ihl,
  261. unsigned int ipl)
  262. {
  263. struct sctphdr *sctph;
  264. if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_SCTP)
  265. return 1;
  266. sctph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*sctph));
  267. if (!sctph)
  268. return 0;
  269. sctph->checksum = sctp_compute_cksum(skb,
  270. skb_network_offset(skb) + ihl);
  271. skb->ip_summed = CHECKSUM_NONE;
  272. skb->csum_not_inet = 0;
  273. return 1;
  274. }
  275. static int tcf_csum_ipv4(struct sk_buff *skb, u32 update_flags)
  276. {
  277. const struct iphdr *iph;
  278. int ntkoff;
  279. ntkoff = skb_network_offset(skb);
  280. if (!pskb_may_pull(skb, sizeof(*iph) + ntkoff))
  281. goto fail;
  282. iph = ip_hdr(skb);
  283. switch (iph->frag_off & htons(IP_OFFSET) ? 0 : iph->protocol) {
  284. case IPPROTO_ICMP:
  285. if (update_flags & TCA_CSUM_UPDATE_FLAG_ICMP)
  286. if (!tcf_csum_ipv4_icmp(skb, iph->ihl * 4,
  287. ntohs(iph->tot_len)))
  288. goto fail;
  289. break;
  290. case IPPROTO_IGMP:
  291. if (update_flags & TCA_CSUM_UPDATE_FLAG_IGMP)
  292. if (!tcf_csum_ipv4_igmp(skb, iph->ihl * 4,
  293. ntohs(iph->tot_len)))
  294. goto fail;
  295. break;
  296. case IPPROTO_TCP:
  297. if (update_flags & TCA_CSUM_UPDATE_FLAG_TCP)
  298. if (!tcf_csum_ipv4_tcp(skb, iph->ihl * 4,
  299. ntohs(iph->tot_len)))
  300. goto fail;
  301. break;
  302. case IPPROTO_UDP:
  303. if (update_flags & TCA_CSUM_UPDATE_FLAG_UDP)
  304. if (!tcf_csum_ipv4_udp(skb, iph->ihl * 4,
  305. ntohs(iph->tot_len), 0))
  306. goto fail;
  307. break;
  308. case IPPROTO_UDPLITE:
  309. if (update_flags & TCA_CSUM_UPDATE_FLAG_UDPLITE)
  310. if (!tcf_csum_ipv4_udp(skb, iph->ihl * 4,
  311. ntohs(iph->tot_len), 1))
  312. goto fail;
  313. break;
  314. case IPPROTO_SCTP:
  315. if ((update_flags & TCA_CSUM_UPDATE_FLAG_SCTP) &&
  316. !tcf_csum_sctp(skb, iph->ihl * 4, ntohs(iph->tot_len)))
  317. goto fail;
  318. break;
  319. }
  320. if (update_flags & TCA_CSUM_UPDATE_FLAG_IPV4HDR) {
  321. if (skb_try_make_writable(skb, sizeof(*iph) + ntkoff))
  322. goto fail;
  323. ip_send_check(ip_hdr(skb));
  324. }
  325. return 1;
  326. fail:
  327. return 0;
  328. }
  329. static int tcf_csum_ipv6_hopopts(struct ipv6_opt_hdr *ip6xh, unsigned int ixhl,
  330. unsigned int *pl)
  331. {
  332. int off, len, optlen;
  333. unsigned char *xh = (void *)ip6xh;
  334. off = sizeof(*ip6xh);
  335. len = ixhl - off;
  336. while (len > 1) {
  337. switch (xh[off]) {
  338. case IPV6_TLV_PAD1:
  339. optlen = 1;
  340. break;
  341. case IPV6_TLV_JUMBO:
  342. optlen = xh[off + 1] + 2;
  343. if (optlen != 6 || len < 6 || (off & 3) != 2)
  344. /* wrong jumbo option length/alignment */
  345. return 0;
  346. *pl = ntohl(*(__be32 *)(xh + off + 2));
  347. goto done;
  348. default:
  349. optlen = xh[off + 1] + 2;
  350. if (optlen > len)
  351. /* ignore obscure options */
  352. goto done;
  353. break;
  354. }
  355. off += optlen;
  356. len -= optlen;
  357. }
  358. done:
  359. return 1;
  360. }
  361. static int tcf_csum_ipv6(struct sk_buff *skb, u32 update_flags)
  362. {
  363. struct ipv6hdr *ip6h;
  364. struct ipv6_opt_hdr *ip6xh;
  365. unsigned int hl, ixhl;
  366. unsigned int pl;
  367. int ntkoff;
  368. u8 nexthdr;
  369. ntkoff = skb_network_offset(skb);
  370. hl = sizeof(*ip6h);
  371. if (!pskb_may_pull(skb, hl + ntkoff))
  372. goto fail;
  373. ip6h = ipv6_hdr(skb);
  374. pl = ntohs(ip6h->payload_len);
  375. nexthdr = ip6h->nexthdr;
  376. do {
  377. switch (nexthdr) {
  378. case NEXTHDR_FRAGMENT:
  379. goto ignore_skb;
  380. case NEXTHDR_ROUTING:
  381. case NEXTHDR_HOP:
  382. case NEXTHDR_DEST:
  383. if (!pskb_may_pull(skb, hl + sizeof(*ip6xh) + ntkoff))
  384. goto fail;
  385. ip6xh = (void *)(skb_network_header(skb) + hl);
  386. ixhl = ipv6_optlen(ip6xh);
  387. if (!pskb_may_pull(skb, hl + ixhl + ntkoff))
  388. goto fail;
  389. ip6xh = (void *)(skb_network_header(skb) + hl);
  390. if ((nexthdr == NEXTHDR_HOP) &&
  391. !(tcf_csum_ipv6_hopopts(ip6xh, ixhl, &pl)))
  392. goto fail;
  393. nexthdr = ip6xh->nexthdr;
  394. hl += ixhl;
  395. break;
  396. case IPPROTO_ICMPV6:
  397. if (update_flags & TCA_CSUM_UPDATE_FLAG_ICMP)
  398. if (!tcf_csum_ipv6_icmp(skb,
  399. hl, pl + sizeof(*ip6h)))
  400. goto fail;
  401. goto done;
  402. case IPPROTO_TCP:
  403. if (update_flags & TCA_CSUM_UPDATE_FLAG_TCP)
  404. if (!tcf_csum_ipv6_tcp(skb,
  405. hl, pl + sizeof(*ip6h)))
  406. goto fail;
  407. goto done;
  408. case IPPROTO_UDP:
  409. if (update_flags & TCA_CSUM_UPDATE_FLAG_UDP)
  410. if (!tcf_csum_ipv6_udp(skb, hl,
  411. pl + sizeof(*ip6h), 0))
  412. goto fail;
  413. goto done;
  414. case IPPROTO_UDPLITE:
  415. if (update_flags & TCA_CSUM_UPDATE_FLAG_UDPLITE)
  416. if (!tcf_csum_ipv6_udp(skb, hl,
  417. pl + sizeof(*ip6h), 1))
  418. goto fail;
  419. goto done;
  420. case IPPROTO_SCTP:
  421. if ((update_flags & TCA_CSUM_UPDATE_FLAG_SCTP) &&
  422. !tcf_csum_sctp(skb, hl, pl + sizeof(*ip6h)))
  423. goto fail;
  424. goto done;
  425. default:
  426. goto ignore_skb;
  427. }
  428. } while (pskb_may_pull(skb, hl + 1 + ntkoff));
  429. done:
  430. ignore_skb:
  431. return 1;
  432. fail:
  433. return 0;
  434. }
  435. static int tcf_csum(struct sk_buff *skb, const struct tc_action *a,
  436. struct tcf_result *res)
  437. {
  438. struct tcf_csum *p = to_tcf_csum(a);
  439. int action;
  440. u32 update_flags;
  441. spin_lock(&p->tcf_lock);
  442. tcf_lastuse_update(&p->tcf_tm);
  443. bstats_update(&p->tcf_bstats, skb);
  444. action = p->tcf_action;
  445. update_flags = p->update_flags;
  446. spin_unlock(&p->tcf_lock);
  447. if (unlikely(action == TC_ACT_SHOT))
  448. goto drop;
  449. switch (tc_skb_protocol(skb)) {
  450. case cpu_to_be16(ETH_P_IP):
  451. if (!tcf_csum_ipv4(skb, update_flags))
  452. goto drop;
  453. break;
  454. case cpu_to_be16(ETH_P_IPV6):
  455. if (!tcf_csum_ipv6(skb, update_flags))
  456. goto drop;
  457. break;
  458. }
  459. return action;
  460. drop:
  461. spin_lock(&p->tcf_lock);
  462. p->tcf_qstats.drops++;
  463. spin_unlock(&p->tcf_lock);
  464. return TC_ACT_SHOT;
  465. }
  466. static int tcf_csum_dump(struct sk_buff *skb, struct tc_action *a, int bind,
  467. int ref)
  468. {
  469. unsigned char *b = skb_tail_pointer(skb);
  470. struct tcf_csum *p = to_tcf_csum(a);
  471. struct tc_csum opt = {
  472. .update_flags = p->update_flags,
  473. .index = p->tcf_index,
  474. .action = p->tcf_action,
  475. .refcnt = p->tcf_refcnt - ref,
  476. .bindcnt = p->tcf_bindcnt - bind,
  477. };
  478. struct tcf_t t;
  479. if (nla_put(skb, TCA_CSUM_PARMS, sizeof(opt), &opt))
  480. goto nla_put_failure;
  481. tcf_tm_dump(&t, &p->tcf_tm);
  482. if (nla_put_64bit(skb, TCA_CSUM_TM, sizeof(t), &t, TCA_CSUM_PAD))
  483. goto nla_put_failure;
  484. return skb->len;
  485. nla_put_failure:
  486. nlmsg_trim(skb, b);
  487. return -1;
  488. }
  489. static int tcf_csum_walker(struct net *net, struct sk_buff *skb,
  490. struct netlink_callback *cb, int type,
  491. const struct tc_action_ops *ops)
  492. {
  493. struct tc_action_net *tn = net_generic(net, csum_net_id);
  494. return tcf_generic_walker(tn, skb, cb, type, ops);
  495. }
  496. static int tcf_csum_search(struct net *net, struct tc_action **a, u32 index)
  497. {
  498. struct tc_action_net *tn = net_generic(net, csum_net_id);
  499. return tcf_hash_search(tn, a, index);
  500. }
  501. static struct tc_action_ops act_csum_ops = {
  502. .kind = "csum",
  503. .type = TCA_ACT_CSUM,
  504. .owner = THIS_MODULE,
  505. .act = tcf_csum,
  506. .dump = tcf_csum_dump,
  507. .init = tcf_csum_init,
  508. .walk = tcf_csum_walker,
  509. .lookup = tcf_csum_search,
  510. .size = sizeof(struct tcf_csum),
  511. };
  512. static __net_init int csum_init_net(struct net *net)
  513. {
  514. struct tc_action_net *tn = net_generic(net, csum_net_id);
  515. return tc_action_net_init(tn, &act_csum_ops, CSUM_TAB_MASK);
  516. }
  517. static void __net_exit csum_exit_net(struct net *net)
  518. {
  519. struct tc_action_net *tn = net_generic(net, csum_net_id);
  520. tc_action_net_exit(tn);
  521. }
  522. static struct pernet_operations csum_net_ops = {
  523. .init = csum_init_net,
  524. .exit = csum_exit_net,
  525. .id = &csum_net_id,
  526. .size = sizeof(struct tc_action_net),
  527. };
  528. MODULE_DESCRIPTION("Checksum updating actions");
  529. MODULE_LICENSE("GPL");
  530. static int __init csum_init_module(void)
  531. {
  532. return tcf_register_action(&act_csum_ops, &csum_net_ops);
  533. }
  534. static void __exit csum_cleanup_module(void)
  535. {
  536. tcf_unregister_action(&act_csum_ops, &csum_net_ops);
  537. }
  538. module_init(csum_init_module);
  539. module_exit(csum_cleanup_module);