static void __exit log_tg_exit(void) { nf_log_unregister(&ipt_log_logger); #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) nf_log_unregister(&ip6t_log_logger); #endif xt_unregister_targets(log_tg_regs, ARRAY_SIZE(log_tg_regs)); }
static void __exit ipt_ulog_fini(void) { ulog_buff_t *ub; int i; DEBUGP("ipt_ULOG: cleanup_module\n"); if (nflog) nf_log_unregister(&ipt_ulog_logger); xt_unregister_target(&ipt_ulog_reg); sock_release(nflognl->sk_socket); /* remove pending timers and free allocated skb's */ for (i = 0; i < ULOG_MAXNLGROUPS; i++) { ub = &ulog_buffers[i]; if (timer_pending(&ub->timer)) { DEBUGP("timer was pending, deleting\n"); del_timer(&ub->timer); } if (ub->skb) { kfree_skb(ub->skb); ub->skb = NULL; } } }
static void __exit ipt_log_fini(void) { nf_log_unregister(&ipt_log_logger); /* remove timer, if it is pending */ if (timer_pending(&timer)) del_timer(&timer); flush_scheduled_work(); syslog_close(&sl_socket); if (loglist_total > 0) printk(KERN_WARNING "ip_SYSLOG: dropping %d log(s). Dropped: %d\n", loglist_total, loglist_dropped + loglist_total); proc_net_remove(&init_net, STAT_PROC_FS_NAME); xt_unregister_target(&ipt_log_reg); }
static void __exit ebt_ulog_fini(void) { ebt_ulog_buff_t *ub; int i; nf_log_unregister(&ebt_ulog_logger); ebt_unregister_watcher(&ulog); for (i = 0; i < EBT_ULOG_MAXNLGROUPS; i++) { ub = &ulog_buffers[i]; if (timer_pending(&ub->timer)) del_timer(&ub->timer); spin_lock_bh(&ub->lock); if (ub->skb) { kfree_skb(ub->skb); ub->skb = NULL; } spin_unlock_bh(&ub->lock); } sock_release(ebtulognl->sk_socket); }
static void __exit ebt_ulog_fini(void) { ebt_ulog_buff_t *ub; int i; nf_log_unregister(&ebt_ulog_logger); xt_unregister_target(&ebt_ulog_tg_reg); for (i = 0; i < EBT_ULOG_MAXNLGROUPS; i++) { ub = &ulog_buffers[i]; if (timer_pending(&ub->timer)) del_timer(&ub->timer); spin_lock_bh(&ub->lock); if (ub->skb) { kfree_skb(ub->skb); ub->skb = NULL; } spin_unlock_bh(&ub->lock); } netlink_kernel_release(ebtulognl); }
static void __exit ebt_log_fini(void) { nf_log_unregister(&ebt_log_logger); xt_unregister_target(&ebt_log_tg_reg); }
static void __exit log_tg_exit(void) { nf_log_unregister(&ipt_log_logger); xt_unregister_target(&log_tg_reg); }
static void __exit nf_log_arp_exit(void) { unregister_pernet_subsys(&nf_log_arp_net_ops); nf_log_unregister(&nf_arp_logger); }
static void __exit ebt_ulog_fini(void) { nf_log_unregister(&ebt_ulog_logger); xt_unregister_target(&ebt_ulog_tg_reg); unregister_pernet_subsys(&ebt_ulog_net_ops); }
static void __exit nf_log_ipv6_exit(void) { unregister_pernet_subsys(&nf_log_ipv6_net_ops); nf_log_unregister(&nf_ip6_logger); }
static void __exit nf_log_bridge_exit(void) { unregister_pernet_subsys(&nf_log_bridge_net_ops); nf_log_unregister(&nf_bridge_logger); }
static void __exit ip6t_log_fini(void) { nf_log_unregister(&ip6t_logger); xt_unregister_target(&ip6t_log_reg); }
static void __exit ebt_log_fini(void) { nf_log_unregister(&ebt_log_logger); ebt_unregister_watcher(&log); }
static void ipt_logfn(unsigned int hooknum, const struct sk_buff *skb, const struct net_device *in, const struct net_device *out, const char *prefix) { struct ipt_ulog_info loginfo = { .nl_group = ULOG_DEFAULT_NLGROUP, .copy_range = 0, .qthreshold = ULOG_DEFAULT_QTHRESHOLD, .prefix = "" }; ipt_ulog_packet(hooknum, skb, in, out, &loginfo, prefix); } static int ipt_ulog_checkentry(const char *tablename, const struct ipt_entry *e, void *targinfo, unsigned int targinfosize, unsigned int hookmask) { struct ipt_ulog_info *loginfo = (struct ipt_ulog_info *) targinfo; if (targinfosize != IPT_ALIGN(sizeof(struct ipt_ulog_info))) { DEBUGP("ipt_ULOG: targinfosize %u != 0\n", targinfosize); return 0; } if (loginfo->prefix[sizeof(loginfo->prefix) - 1] != '\0') { DEBUGP("ipt_ULOG: prefix term %i\n", loginfo->prefix[sizeof(loginfo->prefix) - 1]); return 0; } if (loginfo->qthreshold > ULOG_MAX_QLEN) { DEBUGP("ipt_ULOG: queue threshold %i > MAX_QLEN\n", loginfo->qthreshold); return 0; } return 1; } static struct ipt_target ipt_ulog_reg = { .name = "ULOG", .target = ipt_ulog_target, .checkentry = ipt_ulog_checkentry, .me = THIS_MODULE, }; static int __init init(void) { int i; DEBUGP("ipt_ULOG: init module\n"); if (nlbufsiz >= 128*1024) { printk("Netlink buffer has to be <= 128kB\n"); return -EINVAL; } /* initialize ulog_buffers */ for (i = 0; i < ULOG_MAXNLGROUPS; i++) { init_timer(&ulog_buffers[i].timer); ulog_buffers[i].timer.function = ulog_timer; ulog_buffers[i].timer.data = i; } nflognl = netlink_kernel_create(NETLINK_NFLOG, NULL); if (!nflognl) return -ENOMEM; if (ipt_register_target(&ipt_ulog_reg) != 0) { sock_release(nflognl->sk_socket); return -EINVAL; } if (nflog) nf_log_register(PF_INET, &ipt_logfn); return 0; } static void __exit fini(void) { ulog_buff_t *ub; int i; DEBUGP("ipt_ULOG: cleanup_module\n"); if (nflog) nf_log_unregister(PF_INET, &ipt_logfn); ipt_unregister_target(&ipt_ulog_reg); sock_release(nflognl->sk_socket); /* remove pending timers and free allocated skb's */ for (i = 0; i < ULOG_MAXNLGROUPS; i++) { ub = &ulog_buffers[i]; if (timer_pending(&ub->timer)) { DEBUGP("timer was pending, deleting\n"); del_timer(&ub->timer); } if (ub->skb) { kfree_skb(ub->skb); ub->skb = NULL; } } }
static void ip6t_logfn(unsigned int hooknum, const struct sk_buff *skb, const struct net_device *in, const struct net_device *out, const char *prefix) { struct ip6t_log_info loginfo = { .level = 0, .logflags = IP6T_LOG_MASK, .prefix = "" }; ip6t_log_packet(hooknum, skb, in, out, &loginfo, KERN_WARNING, prefix); } static int ip6t_log_checkentry(const char *tablename, const struct ip6t_entry *e, void *targinfo, unsigned int targinfosize, unsigned int hook_mask) { const struct ip6t_log_info *loginfo = targinfo; if (targinfosize != IP6T_ALIGN(sizeof(struct ip6t_log_info))) { DEBUGP("LOG: targinfosize %u != %u\n", targinfosize, IP6T_ALIGN(sizeof(struct ip6t_log_info))); return 0; } if (loginfo->level >= 8) { DEBUGP("LOG: level %u >= 8\n", loginfo->level); return 0; } if (loginfo->prefix[sizeof(loginfo->prefix)-1] != '\0') { DEBUGP("LOG: prefix term %i\n", loginfo->prefix[sizeof(loginfo->prefix)-1]); return 0; } return 1; } static struct ip6t_target ip6t_log_reg = { .name = "LOG", .target = ip6t_log_target, .checkentry = ip6t_log_checkentry, .me = THIS_MODULE, }; static int __init init(void) { if (ip6t_register_target(&ip6t_log_reg)) return -EINVAL; if (nflog) nf_log_register(PF_INET6, &ip6t_logfn); return 0; } static void __exit fini(void) { if (nflog) nf_log_unregister(PF_INET6, &ip6t_logfn); ip6t_unregister_target(&ip6t_log_reg); } module_init(init); module_exit(fini);