1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * net/sched/act_mirred.c packet mirroring and redirect actions 4 * 5 * Authors: Jamal Hadi Salim (2002-4) 6 * 7 * TODO: Add ingress support (and socket redirect support) 8 */ 9 10 #include <linux/types.h> 11 #include <linux/kernel.h> 12 #include <linux/string.h> 13 #include <linux/errno.h> 14 #include <linux/skbuff.h> 15 #include <linux/rtnetlink.h> 16 #include <linux/module.h> 17 #include <linux/init.h> 18 #include <linux/gfp.h> 19 #include <linux/if_arp.h> 20 #include <net/net_namespace.h> 21 #include <net/netlink.h> 22 #include <net/dst.h> 23 #include <net/pkt_sched.h> 24 #include <net/pkt_cls.h> 25 #include <linux/tc_act/tc_mirred.h> 26 #include <net/tc_act/tc_mirred.h> 27 #include <net/tc_wrapper.h> 28 29 static LIST_HEAD(mirred_list); 30 static DEFINE_SPINLOCK(mirred_list_lock); 31 32 static bool tcf_mirred_is_act_redirect(int action) 33 { 34 return action == TCA_EGRESS_REDIR || action == TCA_INGRESS_REDIR; 35 } 36 37 static bool tcf_mirred_act_wants_ingress(int action) 38 { 39 switch (action) { 40 case TCA_EGRESS_REDIR: 41 case TCA_EGRESS_MIRROR: 42 return false; 43 case TCA_INGRESS_REDIR: 44 case TCA_INGRESS_MIRROR: 45 return true; 46 default: 47 BUG(); 48 } 49 } 50 51 static bool tcf_mirred_can_reinsert(int action) 52 { 53 switch (action) { 54 case TC_ACT_SHOT: 55 case TC_ACT_STOLEN: 56 case TC_ACT_QUEUED: 57 case TC_ACT_TRAP: 58 return true; 59 } 60 return false; 61 } 62 63 static struct net_device *tcf_mirred_dev_dereference(struct tcf_mirred *m) 64 { 65 return rcu_dereference_protected(m->tcfm_dev, 66 lockdep_is_held(&m->tcf_lock)); 67 } 68 69 static void tcf_mirred_release(struct tc_action *a) 70 { 71 struct tcf_mirred *m = to_mirred(a); 72 struct net_device *dev; 73 74 spin_lock(&mirred_list_lock); 75 list_del(&m->tcfm_list); 76 spin_unlock(&mirred_list_lock); 77 78 /* last reference to action, no need to lock */ 79 dev = rcu_dereference_protected(m->tcfm_dev, 1); 80 netdev_put(dev, &m->tcfm_dev_tracker); 81 } 82 83 static const struct nla_policy mirred_policy[TCA_MIRRED_MAX + 1] = { 84 [TCA_MIRRED_PARMS] = { .len = sizeof(struct tc_mirred) }, 85 [TCA_MIRRED_BLOCKID] = NLA_POLICY_MIN(NLA_U32, 1), 86 }; 87 88 static struct tc_action_ops act_mirred_ops; 89 90 static void tcf_mirred_replace_dev(struct tcf_mirred *m, 91 struct net_device *ndev) 92 { 93 struct net_device *odev; 94 95 odev = rcu_replace_pointer(m->tcfm_dev, ndev, 96 lockdep_is_held(&m->tcf_lock)); 97 netdev_put(odev, &m->tcfm_dev_tracker); 98 } 99 100 static int tcf_mirred_init(struct net *net, struct nlattr *nla, 101 struct nlattr *est, struct tc_action **a, 102 struct tcf_proto *tp, 103 u32 flags, struct netlink_ext_ack *extack) 104 { 105 struct tc_action_net *tn = net_generic(net, act_mirred_ops.net_id); 106 bool bind = flags & TCA_ACT_FLAGS_BIND; 107 struct nlattr *tb[TCA_MIRRED_MAX + 1]; 108 struct tcf_chain *goto_ch = NULL; 109 bool mac_header_xmit = false; 110 struct tc_mirred *parm; 111 struct tcf_mirred *m; 112 bool exists = false; 113 int ret, err; 114 u32 index; 115 116 if (!nla) { 117 NL_SET_ERR_MSG_MOD(extack, "Mirred requires attributes to be passed"); 118 return -EINVAL; 119 } 120 ret = nla_parse_nested_deprecated(tb, TCA_MIRRED_MAX, nla, 121 mirred_policy, extack); 122 if (ret < 0) 123 return ret; 124 if (!tb[TCA_MIRRED_PARMS]) { 125 NL_SET_ERR_MSG_MOD(extack, "Missing required mirred parameters"); 126 return -EINVAL; 127 } 128 parm = nla_data(tb[TCA_MIRRED_PARMS]); 129 index = parm->index; 130 err = tcf_idr_check_alloc(tn, &index, a, bind); 131 if (err < 0) 132 return err; 133 exists = err; 134 if (exists && bind) 135 return ACT_P_BOUND; 136 137 if (tb[TCA_MIRRED_BLOCKID] && parm->ifindex) { 138 NL_SET_ERR_MSG_MOD(extack, 139 "Cannot specify Block ID and dev simultaneously"); 140 if (exists) 141 tcf_idr_release(*a, bind); 142 else 143 tcf_idr_cleanup(tn, index); 144 145 return -EINVAL; 146 } 147 148 switch (parm->eaction) { 149 case TCA_EGRESS_MIRROR: 150 case TCA_EGRESS_REDIR: 151 case TCA_INGRESS_REDIR: 152 case TCA_INGRESS_MIRROR: 153 break; 154 default: 155 if (exists) 156 tcf_idr_release(*a, bind); 157 else 158 tcf_idr_cleanup(tn, index); 159 NL_SET_ERR_MSG_MOD(extack, "Unknown mirred option"); 160 return -EINVAL; 161 } 162 163 if (!exists) { 164 if (!parm->ifindex && !tb[TCA_MIRRED_BLOCKID]) { 165 tcf_idr_cleanup(tn, index); 166 NL_SET_ERR_MSG_MOD(extack, 167 "Must specify device or block"); 168 return -EINVAL; 169 } 170 ret = tcf_idr_create_from_flags(tn, index, est, a, 171 &act_mirred_ops, bind, flags); 172 if (ret) { 173 tcf_idr_cleanup(tn, index); 174 return ret; 175 } 176 ret = ACT_P_CREATED; 177 } else if (!(flags & TCA_ACT_FLAGS_REPLACE)) { 178 tcf_idr_release(*a, bind); 179 return -EEXIST; 180 } 181 182 m = to_mirred(*a); 183 if (ret == ACT_P_CREATED) 184 INIT_LIST_HEAD(&m->tcfm_list); 185 186 err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack); 187 if (err < 0) 188 goto release_idr; 189 190 spin_lock_bh(&m->tcf_lock); 191 192 if (parm->ifindex) { 193 struct net_device *ndev; 194 195 ndev = dev_get_by_index(net, parm->ifindex); 196 if (!ndev) { 197 spin_unlock_bh(&m->tcf_lock); 198 err = -ENODEV; 199 goto put_chain; 200 } 201 mac_header_xmit = dev_is_mac_header_xmit(ndev); 202 tcf_mirred_replace_dev(m, ndev); 203 netdev_tracker_alloc(ndev, &m->tcfm_dev_tracker, GFP_ATOMIC); 204 m->tcfm_mac_header_xmit = mac_header_xmit; 205 m->tcfm_blockid = 0; 206 } else if (tb[TCA_MIRRED_BLOCKID]) { 207 tcf_mirred_replace_dev(m, NULL); 208 m->tcfm_mac_header_xmit = false; 209 m->tcfm_blockid = nla_get_u32(tb[TCA_MIRRED_BLOCKID]); 210 } 211 goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); 212 m->tcfm_eaction = parm->eaction; 213 spin_unlock_bh(&m->tcf_lock); 214 if (goto_ch) 215 tcf_chain_put_by_act(goto_ch); 216 217 if (ret == ACT_P_CREATED) { 218 spin_lock(&mirred_list_lock); 219 list_add(&m->tcfm_list, &mirred_list); 220 spin_unlock(&mirred_list_lock); 221 } 222 223 return ret; 224 put_chain: 225 if (goto_ch) 226 tcf_chain_put_by_act(goto_ch); 227 release_idr: 228 tcf_idr_release(*a, bind); 229 return err; 230 } 231 232 static int 233 tcf_mirred_forward(bool at_ingress, bool want_ingress, struct sk_buff *skb) 234 { 235 int err; 236 237 if (!want_ingress) 238 err = tcf_dev_queue_xmit(skb, dev_queue_xmit); 239 else if (!at_ingress) 240 err = netif_rx(skb); 241 else 242 err = netif_receive_skb(skb); 243 244 return err; 245 } 246 247 static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m, 248 struct net_device *dev, 249 const bool m_mac_header_xmit, int m_eaction, 250 int retval) 251 { 252 struct sk_buff *skb_to_send = skb; 253 bool want_ingress; 254 bool is_redirect; 255 bool expects_nh; 256 bool at_ingress; 257 bool dont_clone; 258 int mac_len; 259 bool at_nh; 260 int err; 261 262 is_redirect = tcf_mirred_is_act_redirect(m_eaction); 263 if (unlikely(!(dev->flags & IFF_UP)) || !netif_carrier_ok(dev)) { 264 net_notice_ratelimited("tc mirred to Houston: device %s is down\n", 265 dev->name); 266 goto err_cant_do; 267 } 268 269 /* we could easily avoid the clone only if called by ingress and clsact; 270 * since we can't easily detect the clsact caller, skip clone only for 271 * ingress - that covers the TC S/W datapath. 272 */ 273 at_ingress = skb_at_tc_ingress(skb); 274 dont_clone = skb_at_tc_ingress(skb) && is_redirect && 275 tcf_mirred_can_reinsert(retval); 276 if (!dont_clone) { 277 skb_to_send = skb_clone(skb, GFP_ATOMIC); 278 if (!skb_to_send) 279 goto err_cant_do; 280 } 281 282 want_ingress = tcf_mirred_act_wants_ingress(m_eaction); 283 284 /* All mirred/redirected skbs should clear previous ct info */ 285 nf_reset_ct(skb_to_send); 286 if (want_ingress && !at_ingress) /* drop dst for egress -> ingress */ 287 skb_dst_drop(skb_to_send); 288 289 expects_nh = want_ingress || !m_mac_header_xmit; 290 at_nh = skb->data == skb_network_header(skb); 291 if (at_nh != expects_nh) { 292 mac_len = at_ingress ? skb->mac_len : 293 skb_network_offset(skb); 294 if (expects_nh) { 295 /* target device/action expect data at nh */ 296 skb_pull_rcsum(skb_to_send, mac_len); 297 } else { 298 /* target device/action expect data at mac */ 299 skb_push_rcsum(skb_to_send, mac_len); 300 } 301 } 302 303 skb_to_send->skb_iif = skb->dev->ifindex; 304 skb_to_send->dev = dev; 305 306 if (is_redirect) { 307 if (skb == skb_to_send) 308 retval = TC_ACT_CONSUMED; 309 310 skb_set_redirected(skb_to_send, skb_to_send->tc_at_ingress); 311 312 err = tcf_mirred_forward(at_ingress, want_ingress, skb_to_send); 313 } else { 314 err = tcf_mirred_forward(at_ingress, want_ingress, skb_to_send); 315 } 316 if (err) 317 tcf_action_inc_overlimit_qstats(&m->common); 318 319 return retval; 320 321 err_cant_do: 322 if (is_redirect) 323 retval = TC_ACT_SHOT; 324 tcf_action_inc_overlimit_qstats(&m->common); 325 return retval; 326 } 327 328 static int tcf_blockcast_redir(struct sk_buff *skb, struct tcf_mirred *m, 329 struct tcf_block *block, int m_eaction, 330 const u32 exception_ifindex, int retval) 331 { 332 struct net_device *dev_prev = NULL; 333 struct net_device *dev = NULL; 334 unsigned long index; 335 int mirred_eaction; 336 337 mirred_eaction = tcf_mirred_act_wants_ingress(m_eaction) ? 338 TCA_INGRESS_MIRROR : TCA_EGRESS_MIRROR; 339 340 xa_for_each(&block->ports, index, dev) { 341 if (index == exception_ifindex) 342 continue; 343 344 if (!dev_prev) 345 goto assign_prev; 346 347 tcf_mirred_to_dev(skb, m, dev_prev, 348 dev_is_mac_header_xmit(dev), 349 mirred_eaction, retval); 350 assign_prev: 351 dev_prev = dev; 352 } 353 354 if (dev_prev) 355 return tcf_mirred_to_dev(skb, m, dev_prev, 356 dev_is_mac_header_xmit(dev_prev), 357 m_eaction, retval); 358 359 return retval; 360 } 361 362 static int tcf_blockcast_mirror(struct sk_buff *skb, struct tcf_mirred *m, 363 struct tcf_block *block, int m_eaction, 364 const u32 exception_ifindex, int retval) 365 { 366 struct net_device *dev = NULL; 367 unsigned long index; 368 369 xa_for_each(&block->ports, index, dev) { 370 if (index == exception_ifindex) 371 continue; 372 373 tcf_mirred_to_dev(skb, m, dev, 374 dev_is_mac_header_xmit(dev), 375 m_eaction, retval); 376 } 377 378 return retval; 379 } 380 381 static int tcf_blockcast(struct sk_buff *skb, struct tcf_mirred *m, 382 const u32 blockid, struct tcf_result *res, 383 int retval) 384 { 385 const u32 exception_ifindex = skb->dev->ifindex; 386 struct tcf_block *block; 387 bool is_redirect; 388 int m_eaction; 389 390 m_eaction = READ_ONCE(m->tcfm_eaction); 391 is_redirect = tcf_mirred_is_act_redirect(m_eaction); 392 393 /* we are already under rcu protection, so can call block lookup 394 * directly. 395 */ 396 block = tcf_block_lookup(dev_net(skb->dev), blockid); 397 if (!block || xa_empty(&block->ports)) { 398 tcf_action_inc_overlimit_qstats(&m->common); 399 return retval; 400 } 401 402 if (is_redirect) 403 return tcf_blockcast_redir(skb, m, block, m_eaction, 404 exception_ifindex, retval); 405 406 /* If it's not redirect, it is mirror */ 407 return tcf_blockcast_mirror(skb, m, block, m_eaction, exception_ifindex, 408 retval); 409 } 410 411 TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb, 412 const struct tc_action *a, 413 struct tcf_result *res) 414 { 415 struct tcf_mirred *m = to_mirred(a); 416 int retval = READ_ONCE(m->tcf_action); 417 struct netdev_xmit *xmit; 418 bool m_mac_header_xmit; 419 struct net_device *dev; 420 int i, m_eaction; 421 u32 blockid; 422 423 #ifdef CONFIG_PREEMPT_RT 424 xmit = ¤t->net_xmit; 425 #else 426 xmit = this_cpu_ptr(&softnet_data.xmit); 427 #endif 428 if (unlikely(xmit->sched_mirred_nest >= MIRRED_NEST_LIMIT)) { 429 net_warn_ratelimited("Packet exceeded mirred recursion limit on dev %s\n", 430 netdev_name(skb->dev)); 431 return TC_ACT_SHOT; 432 } 433 434 tcf_lastuse_update(&m->tcf_tm); 435 tcf_action_update_bstats(&m->common, skb); 436 437 blockid = READ_ONCE(m->tcfm_blockid); 438 if (blockid) 439 return tcf_blockcast(skb, m, blockid, res, retval); 440 441 dev = rcu_dereference_bh(m->tcfm_dev); 442 if (unlikely(!dev)) { 443 pr_notice_once("tc mirred: target device is gone\n"); 444 tcf_action_inc_overlimit_qstats(&m->common); 445 return retval; 446 } 447 for (i = 0; i < xmit->sched_mirred_nest; i++) { 448 if (xmit->sched_mirred_dev[i] != dev) 449 continue; 450 pr_notice_once("tc mirred: loop on device %s\n", 451 netdev_name(dev)); 452 tcf_action_inc_overlimit_qstats(&m->common); 453 return retval; 454 } 455 456 xmit->sched_mirred_dev[xmit->sched_mirred_nest++] = dev; 457 458 m_mac_header_xmit = READ_ONCE(m->tcfm_mac_header_xmit); 459 m_eaction = READ_ONCE(m->tcfm_eaction); 460 461 retval = tcf_mirred_to_dev(skb, m, dev, m_mac_header_xmit, m_eaction, 462 retval); 463 xmit->sched_mirred_nest--; 464 465 return retval; 466 } 467 468 static void tcf_stats_update(struct tc_action *a, u64 bytes, u64 packets, 469 u64 drops, u64 lastuse, bool hw) 470 { 471 struct tcf_mirred *m = to_mirred(a); 472 struct tcf_t *tm = &m->tcf_tm; 473 474 tcf_action_update_stats(a, bytes, packets, drops, hw); 475 tm->lastuse = max_t(u64, tm->lastuse, lastuse); 476 } 477 478 static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind, 479 int ref) 480 { 481 unsigned char *b = skb_tail_pointer(skb); 482 struct tcf_mirred *m = to_mirred(a); 483 struct tc_mirred opt = { 484 .index = m->tcf_index, 485 .refcnt = refcount_read(&m->tcf_refcnt) - ref, 486 .bindcnt = atomic_read(&m->tcf_bindcnt) - bind, 487 }; 488 struct net_device *dev; 489 struct tcf_t t; 490 u32 blockid; 491 492 spin_lock_bh(&m->tcf_lock); 493 opt.action = m->tcf_action; 494 opt.eaction = m->tcfm_eaction; 495 dev = tcf_mirred_dev_dereference(m); 496 if (dev) 497 opt.ifindex = dev->ifindex; 498 499 if (nla_put(skb, TCA_MIRRED_PARMS, sizeof(opt), &opt)) 500 goto nla_put_failure; 501 502 blockid = m->tcfm_blockid; 503 if (blockid && nla_put_u32(skb, TCA_MIRRED_BLOCKID, blockid)) 504 goto nla_put_failure; 505 506 tcf_tm_dump(&t, &m->tcf_tm); 507 if (nla_put_64bit(skb, TCA_MIRRED_TM, sizeof(t), &t, TCA_MIRRED_PAD)) 508 goto nla_put_failure; 509 spin_unlock_bh(&m->tcf_lock); 510 511 return skb->len; 512 513 nla_put_failure: 514 spin_unlock_bh(&m->tcf_lock); 515 nlmsg_trim(skb, b); 516 return -1; 517 } 518 519 static int mirred_device_event(struct notifier_block *unused, 520 unsigned long event, void *ptr) 521 { 522 struct net_device *dev = netdev_notifier_info_to_dev(ptr); 523 struct tcf_mirred *m; 524 525 ASSERT_RTNL(); 526 if (event == NETDEV_UNREGISTER) { 527 spin_lock(&mirred_list_lock); 528 list_for_each_entry(m, &mirred_list, tcfm_list) { 529 spin_lock_bh(&m->tcf_lock); 530 if (tcf_mirred_dev_dereference(m) == dev) { 531 netdev_put(dev, &m->tcfm_dev_tracker); 532 /* Note : no rcu grace period necessary, as 533 * net_device are already rcu protected. 534 */ 535 RCU_INIT_POINTER(m->tcfm_dev, NULL); 536 } 537 spin_unlock_bh(&m->tcf_lock); 538 } 539 spin_unlock(&mirred_list_lock); 540 } 541 542 return NOTIFY_DONE; 543 } 544 545 static struct notifier_block mirred_device_notifier = { 546 .notifier_call = mirred_device_event, 547 }; 548 549 static void tcf_mirred_dev_put(void *priv) 550 { 551 struct net_device *dev = priv; 552 553 dev_put(dev); 554 } 555 556 static struct net_device * 557 tcf_mirred_get_dev(const struct tc_action *a, 558 tc_action_priv_destructor *destructor) 559 { 560 struct tcf_mirred *m = to_mirred(a); 561 struct net_device *dev; 562 563 rcu_read_lock(); 564 dev = rcu_dereference(m->tcfm_dev); 565 if (dev) { 566 dev_hold(dev); 567 *destructor = tcf_mirred_dev_put; 568 } 569 rcu_read_unlock(); 570 571 return dev; 572 } 573 574 static size_t tcf_mirred_get_fill_size(const struct tc_action *act) 575 { 576 return nla_total_size(sizeof(struct tc_mirred)); 577 } 578 579 static void tcf_offload_mirred_get_dev(struct flow_action_entry *entry, 580 const struct tc_action *act) 581 { 582 entry->dev = act->ops->get_dev(act, &entry->destructor); 583 if (!entry->dev) 584 return; 585 entry->destructor_priv = entry->dev; 586 } 587 588 static int tcf_mirred_offload_act_setup(struct tc_action *act, void *entry_data, 589 u32 *index_inc, bool bind, 590 struct netlink_ext_ack *extack) 591 { 592 if (bind) { 593 struct flow_action_entry *entry = entry_data; 594 595 if (is_tcf_mirred_egress_redirect(act)) { 596 entry->id = FLOW_ACTION_REDIRECT; 597 tcf_offload_mirred_get_dev(entry, act); 598 } else if (is_tcf_mirred_egress_mirror(act)) { 599 entry->id = FLOW_ACTION_MIRRED; 600 tcf_offload_mirred_get_dev(entry, act); 601 } else if (is_tcf_mirred_ingress_redirect(act)) { 602 entry->id = FLOW_ACTION_REDIRECT_INGRESS; 603 tcf_offload_mirred_get_dev(entry, act); 604 } else if (is_tcf_mirred_ingress_mirror(act)) { 605 entry->id = FLOW_ACTION_MIRRED_INGRESS; 606 tcf_offload_mirred_get_dev(entry, act); 607 } else { 608 NL_SET_ERR_MSG_MOD(extack, "Unsupported mirred offload"); 609 return -EOPNOTSUPP; 610 } 611 *index_inc = 1; 612 } else { 613 struct flow_offload_action *fl_action = entry_data; 614 615 if (is_tcf_mirred_egress_redirect(act)) 616 fl_action->id = FLOW_ACTION_REDIRECT; 617 else if (is_tcf_mirred_egress_mirror(act)) 618 fl_action->id = FLOW_ACTION_MIRRED; 619 else if (is_tcf_mirred_ingress_redirect(act)) 620 fl_action->id = FLOW_ACTION_REDIRECT_INGRESS; 621 else if (is_tcf_mirred_ingress_mirror(act)) 622 fl_action->id = FLOW_ACTION_MIRRED_INGRESS; 623 else 624 return -EOPNOTSUPP; 625 } 626 627 return 0; 628 } 629 630 static struct tc_action_ops act_mirred_ops = { 631 .kind = "mirred", 632 .id = TCA_ID_MIRRED, 633 .owner = THIS_MODULE, 634 .act = tcf_mirred_act, 635 .stats_update = tcf_stats_update, 636 .dump = tcf_mirred_dump, 637 .cleanup = tcf_mirred_release, 638 .init = tcf_mirred_init, 639 .get_fill_size = tcf_mirred_get_fill_size, 640 .offload_act_setup = tcf_mirred_offload_act_setup, 641 .size = sizeof(struct tcf_mirred), 642 .get_dev = tcf_mirred_get_dev, 643 }; 644 MODULE_ALIAS_NET_ACT("mirred"); 645 646 static __net_init int mirred_init_net(struct net *net) 647 { 648 struct tc_action_net *tn = net_generic(net, act_mirred_ops.net_id); 649 650 return tc_action_net_init(net, tn, &act_mirred_ops); 651 } 652 653 static void __net_exit mirred_exit_net(struct list_head *net_list) 654 { 655 tc_action_net_exit(net_list, act_mirred_ops.net_id); 656 } 657 658 static struct pernet_operations mirred_net_ops = { 659 .init = mirred_init_net, 660 .exit_batch = mirred_exit_net, 661 .id = &act_mirred_ops.net_id, 662 .size = sizeof(struct tc_action_net), 663 }; 664 665 MODULE_AUTHOR("Jamal Hadi Salim(2002)"); 666 MODULE_DESCRIPTION("Device Mirror/redirect actions"); 667 MODULE_LICENSE("GPL"); 668 669 static int __init mirred_init_module(void) 670 { 671 int err = register_netdevice_notifier(&mirred_device_notifier); 672 if (err) 673 return err; 674 675 pr_info("Mirror/redirect action on\n"); 676 err = tcf_register_action(&act_mirred_ops, &mirred_net_ops); 677 if (err) 678 unregister_netdevice_notifier(&mirred_device_notifier); 679 680 return err; 681 } 682 683 static void __exit mirred_cleanup_module(void) 684 { 685 tcf_unregister_action(&act_mirred_ops, &mirred_net_ops); 686 unregister_netdevice_notifier(&mirred_device_notifier); 687 } 688 689 module_init(mirred_init_module); 690 module_exit(mirred_cleanup_module); 691