act_csum.c 15 KB

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