act_csum.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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. if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
  187. return 1;
  188. /*
  189. * Support both UDP and UDPLITE checksum algorithms, Don't use
  190. * udph->len to get the real length without any protocol check,
  191. * UDPLITE uses udph->len for another thing,
  192. * Use iph->tot_len, or just ipl.
  193. */
  194. udph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*udph));
  195. if (udph == NULL)
  196. return 0;
  197. iph = ip_hdr(skb);
  198. ul = ntohs(udph->len);
  199. if (udplite || udph->check) {
  200. udph->check = 0;
  201. if (udplite) {
  202. if (ul == 0)
  203. skb->csum = csum_partial(udph, ipl - ihl, 0);
  204. else if ((ul >= sizeof(*udph)) && (ul <= ipl - ihl))
  205. skb->csum = csum_partial(udph, ul, 0);
  206. else
  207. goto ignore_obscure_skb;
  208. } else {
  209. if (ul != ipl - ihl)
  210. goto ignore_obscure_skb;
  211. skb->csum = csum_partial(udph, ul, 0);
  212. }
  213. udph->check = csum_tcpudp_magic(iph->saddr, iph->daddr,
  214. ul, iph->protocol,
  215. skb->csum);
  216. if (!udph->check)
  217. udph->check = CSUM_MANGLED_0;
  218. }
  219. skb->ip_summed = CHECKSUM_NONE;
  220. ignore_obscure_skb:
  221. return 1;
  222. }
  223. static int tcf_csum_ipv6_udp(struct sk_buff *skb, unsigned int ihl,
  224. unsigned int ipl, int udplite)
  225. {
  226. struct udphdr *udph;
  227. const struct ipv6hdr *ip6h;
  228. u16 ul;
  229. if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
  230. return 1;
  231. /*
  232. * Support both UDP and UDPLITE checksum algorithms, Don't use
  233. * udph->len to get the real length without any protocol check,
  234. * UDPLITE uses udph->len for another thing,
  235. * Use ip6h->payload_len + sizeof(*ip6h) ... , or just ipl.
  236. */
  237. udph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*udph));
  238. if (udph == NULL)
  239. return 0;
  240. ip6h = ipv6_hdr(skb);
  241. ul = ntohs(udph->len);
  242. udph->check = 0;
  243. if (udplite) {
  244. if (ul == 0)
  245. skb->csum = csum_partial(udph, ipl - ihl, 0);
  246. else if ((ul >= sizeof(*udph)) && (ul <= ipl - ihl))
  247. skb->csum = csum_partial(udph, ul, 0);
  248. else
  249. goto ignore_obscure_skb;
  250. } else {
  251. if (ul != ipl - ihl)
  252. goto ignore_obscure_skb;
  253. skb->csum = csum_partial(udph, ul, 0);
  254. }
  255. udph->check = csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, ul,
  256. udplite ? IPPROTO_UDPLITE : IPPROTO_UDP,
  257. skb->csum);
  258. if (!udph->check)
  259. udph->check = CSUM_MANGLED_0;
  260. skb->ip_summed = CHECKSUM_NONE;
  261. ignore_obscure_skb:
  262. return 1;
  263. }
  264. static int tcf_csum_sctp(struct sk_buff *skb, unsigned int ihl,
  265. unsigned int ipl)
  266. {
  267. struct sctphdr *sctph;
  268. if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_SCTP)
  269. return 1;
  270. sctph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*sctph));
  271. if (!sctph)
  272. return 0;
  273. sctph->checksum = sctp_compute_cksum(skb,
  274. skb_network_offset(skb) + ihl);
  275. skb->ip_summed = CHECKSUM_NONE;
  276. skb->csum_not_inet = 0;
  277. return 1;
  278. }
  279. static int tcf_csum_ipv4(struct sk_buff *skb, u32 update_flags)
  280. {
  281. const struct iphdr *iph;
  282. int ntkoff;
  283. ntkoff = skb_network_offset(skb);
  284. if (!pskb_may_pull(skb, sizeof(*iph) + ntkoff))
  285. goto fail;
  286. iph = ip_hdr(skb);
  287. switch (iph->frag_off & htons(IP_OFFSET) ? 0 : iph->protocol) {
  288. case IPPROTO_ICMP:
  289. if (update_flags & TCA_CSUM_UPDATE_FLAG_ICMP)
  290. if (!tcf_csum_ipv4_icmp(skb, iph->ihl * 4,
  291. ntohs(iph->tot_len)))
  292. goto fail;
  293. break;
  294. case IPPROTO_IGMP:
  295. if (update_flags & TCA_CSUM_UPDATE_FLAG_IGMP)
  296. if (!tcf_csum_ipv4_igmp(skb, iph->ihl * 4,
  297. ntohs(iph->tot_len)))
  298. goto fail;
  299. break;
  300. case IPPROTO_TCP:
  301. if (update_flags & TCA_CSUM_UPDATE_FLAG_TCP)
  302. if (!tcf_csum_ipv4_tcp(skb, iph->ihl * 4,
  303. ntohs(iph->tot_len)))
  304. goto fail;
  305. break;
  306. case IPPROTO_UDP:
  307. if (update_flags & TCA_CSUM_UPDATE_FLAG_UDP)
  308. if (!tcf_csum_ipv4_udp(skb, iph->ihl * 4,
  309. ntohs(iph->tot_len), 0))
  310. goto fail;
  311. break;
  312. case IPPROTO_UDPLITE:
  313. if (update_flags & TCA_CSUM_UPDATE_FLAG_UDPLITE)
  314. if (!tcf_csum_ipv4_udp(skb, iph->ihl * 4,
  315. ntohs(iph->tot_len), 1))
  316. goto fail;
  317. break;
  318. case IPPROTO_SCTP:
  319. if ((update_flags & TCA_CSUM_UPDATE_FLAG_SCTP) &&
  320. !tcf_csum_sctp(skb, iph->ihl * 4, ntohs(iph->tot_len)))
  321. goto fail;
  322. break;
  323. }
  324. if (update_flags & TCA_CSUM_UPDATE_FLAG_IPV4HDR) {
  325. if (skb_try_make_writable(skb, sizeof(*iph) + ntkoff))
  326. goto fail;
  327. ip_send_check(ip_hdr(skb));
  328. }
  329. return 1;
  330. fail:
  331. return 0;
  332. }
  333. static int tcf_csum_ipv6_hopopts(struct ipv6_opt_hdr *ip6xh, unsigned int ixhl,
  334. unsigned int *pl)
  335. {
  336. int off, len, optlen;
  337. unsigned char *xh = (void *)ip6xh;
  338. off = sizeof(*ip6xh);
  339. len = ixhl - off;
  340. while (len > 1) {
  341. switch (xh[off]) {
  342. case IPV6_TLV_PAD1:
  343. optlen = 1;
  344. break;
  345. case IPV6_TLV_JUMBO:
  346. optlen = xh[off + 1] + 2;
  347. if (optlen != 6 || len < 6 || (off & 3) != 2)
  348. /* wrong jumbo option length/alignment */
  349. return 0;
  350. *pl = ntohl(*(__be32 *)(xh + off + 2));
  351. goto done;
  352. default:
  353. optlen = xh[off + 1] + 2;
  354. if (optlen > len)
  355. /* ignore obscure options */
  356. goto done;
  357. break;
  358. }
  359. off += optlen;
  360. len -= optlen;
  361. }
  362. done:
  363. return 1;
  364. }
  365. static int tcf_csum_ipv6(struct sk_buff *skb, u32 update_flags)
  366. {
  367. struct ipv6hdr *ip6h;
  368. struct ipv6_opt_hdr *ip6xh;
  369. unsigned int hl, ixhl;
  370. unsigned int pl;
  371. int ntkoff;
  372. u8 nexthdr;
  373. ntkoff = skb_network_offset(skb);
  374. hl = sizeof(*ip6h);
  375. if (!pskb_may_pull(skb, hl + ntkoff))
  376. goto fail;
  377. ip6h = ipv6_hdr(skb);
  378. pl = ntohs(ip6h->payload_len);
  379. nexthdr = ip6h->nexthdr;
  380. do {
  381. switch (nexthdr) {
  382. case NEXTHDR_FRAGMENT:
  383. goto ignore_skb;
  384. case NEXTHDR_ROUTING:
  385. case NEXTHDR_HOP:
  386. case NEXTHDR_DEST:
  387. if (!pskb_may_pull(skb, hl + sizeof(*ip6xh) + ntkoff))
  388. goto fail;
  389. ip6xh = (void *)(skb_network_header(skb) + hl);
  390. ixhl = ipv6_optlen(ip6xh);
  391. if (!pskb_may_pull(skb, hl + ixhl + ntkoff))
  392. goto fail;
  393. ip6xh = (void *)(skb_network_header(skb) + hl);
  394. if ((nexthdr == NEXTHDR_HOP) &&
  395. !(tcf_csum_ipv6_hopopts(ip6xh, ixhl, &pl)))
  396. goto fail;
  397. nexthdr = ip6xh->nexthdr;
  398. hl += ixhl;
  399. break;
  400. case IPPROTO_ICMPV6:
  401. if (update_flags & TCA_CSUM_UPDATE_FLAG_ICMP)
  402. if (!tcf_csum_ipv6_icmp(skb,
  403. hl, pl + sizeof(*ip6h)))
  404. goto fail;
  405. goto done;
  406. case IPPROTO_TCP:
  407. if (update_flags & TCA_CSUM_UPDATE_FLAG_TCP)
  408. if (!tcf_csum_ipv6_tcp(skb,
  409. hl, pl + sizeof(*ip6h)))
  410. goto fail;
  411. goto done;
  412. case IPPROTO_UDP:
  413. if (update_flags & TCA_CSUM_UPDATE_FLAG_UDP)
  414. if (!tcf_csum_ipv6_udp(skb, hl,
  415. pl + sizeof(*ip6h), 0))
  416. goto fail;
  417. goto done;
  418. case IPPROTO_UDPLITE:
  419. if (update_flags & TCA_CSUM_UPDATE_FLAG_UDPLITE)
  420. if (!tcf_csum_ipv6_udp(skb, hl,
  421. pl + sizeof(*ip6h), 1))
  422. goto fail;
  423. goto done;
  424. case IPPROTO_SCTP:
  425. if ((update_flags & TCA_CSUM_UPDATE_FLAG_SCTP) &&
  426. !tcf_csum_sctp(skb, hl, pl + sizeof(*ip6h)))
  427. goto fail;
  428. goto done;
  429. default:
  430. goto ignore_skb;
  431. }
  432. } while (pskb_may_pull(skb, hl + 1 + ntkoff));
  433. done:
  434. ignore_skb:
  435. return 1;
  436. fail:
  437. return 0;
  438. }
  439. static int tcf_csum(struct sk_buff *skb, const struct tc_action *a,
  440. struct tcf_result *res)
  441. {
  442. struct tcf_csum *p = to_tcf_csum(a);
  443. int action;
  444. u32 update_flags;
  445. spin_lock(&p->tcf_lock);
  446. tcf_lastuse_update(&p->tcf_tm);
  447. bstats_update(&p->tcf_bstats, skb);
  448. action = p->tcf_action;
  449. update_flags = p->update_flags;
  450. spin_unlock(&p->tcf_lock);
  451. if (unlikely(action == TC_ACT_SHOT))
  452. goto drop;
  453. switch (tc_skb_protocol(skb)) {
  454. case cpu_to_be16(ETH_P_IP):
  455. if (!tcf_csum_ipv4(skb, update_flags))
  456. goto drop;
  457. break;
  458. case cpu_to_be16(ETH_P_IPV6):
  459. if (!tcf_csum_ipv6(skb, update_flags))
  460. goto drop;
  461. break;
  462. }
  463. return action;
  464. drop:
  465. spin_lock(&p->tcf_lock);
  466. p->tcf_qstats.drops++;
  467. spin_unlock(&p->tcf_lock);
  468. return TC_ACT_SHOT;
  469. }
  470. static int tcf_csum_dump(struct sk_buff *skb, struct tc_action *a, int bind,
  471. int ref)
  472. {
  473. unsigned char *b = skb_tail_pointer(skb);
  474. struct tcf_csum *p = to_tcf_csum(a);
  475. struct tc_csum opt = {
  476. .update_flags = p->update_flags,
  477. .index = p->tcf_index,
  478. .action = p->tcf_action,
  479. .refcnt = p->tcf_refcnt - ref,
  480. .bindcnt = p->tcf_bindcnt - bind,
  481. };
  482. struct tcf_t t;
  483. if (nla_put(skb, TCA_CSUM_PARMS, sizeof(opt), &opt))
  484. goto nla_put_failure;
  485. tcf_tm_dump(&t, &p->tcf_tm);
  486. if (nla_put_64bit(skb, TCA_CSUM_TM, sizeof(t), &t, TCA_CSUM_PAD))
  487. goto nla_put_failure;
  488. return skb->len;
  489. nla_put_failure:
  490. nlmsg_trim(skb, b);
  491. return -1;
  492. }
  493. static int tcf_csum_walker(struct net *net, struct sk_buff *skb,
  494. struct netlink_callback *cb, int type,
  495. const struct tc_action_ops *ops)
  496. {
  497. struct tc_action_net *tn = net_generic(net, csum_net_id);
  498. return tcf_generic_walker(tn, skb, cb, type, ops);
  499. }
  500. static int tcf_csum_search(struct net *net, struct tc_action **a, u32 index)
  501. {
  502. struct tc_action_net *tn = net_generic(net, csum_net_id);
  503. return tcf_hash_search(tn, a, index);
  504. }
  505. static struct tc_action_ops act_csum_ops = {
  506. .kind = "csum",
  507. .type = TCA_ACT_CSUM,
  508. .owner = THIS_MODULE,
  509. .act = tcf_csum,
  510. .dump = tcf_csum_dump,
  511. .init = tcf_csum_init,
  512. .walk = tcf_csum_walker,
  513. .lookup = tcf_csum_search,
  514. .size = sizeof(struct tcf_csum),
  515. };
  516. static __net_init int csum_init_net(struct net *net)
  517. {
  518. struct tc_action_net *tn = net_generic(net, csum_net_id);
  519. return tc_action_net_init(tn, &act_csum_ops, CSUM_TAB_MASK);
  520. }
  521. static void __net_exit csum_exit_net(struct net *net)
  522. {
  523. struct tc_action_net *tn = net_generic(net, csum_net_id);
  524. tc_action_net_exit(tn);
  525. }
  526. static struct pernet_operations csum_net_ops = {
  527. .init = csum_init_net,
  528. .exit = csum_exit_net,
  529. .id = &csum_net_id,
  530. .size = sizeof(struct tc_action_net),
  531. };
  532. MODULE_DESCRIPTION("Checksum updating actions");
  533. MODULE_LICENSE("GPL");
  534. static int __init csum_init_module(void)
  535. {
  536. return tcf_register_action(&act_csum_ops, &csum_net_ops);
  537. }
  538. static void __exit csum_cleanup_module(void)
  539. {
  540. tcf_unregister_action(&act_csum_ops, &csum_net_ops);
  541. }
  542. module_init(csum_init_module);
  543. module_exit(csum_cleanup_module);