~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/bridge/netfilter/ebt_redirect.c

Version: ~ [ linux-5.16-rc3 ] ~ [ linux-5.15.5 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.82 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.162 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.218 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.256 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.291 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.293 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  ebt_redirect
  3  *
  4  *      Authors:
  5  *      Bart De Schuymer <bdschuym@pandora.be>
  6  *
  7  *  April, 2002
  8  *
  9  */
 10 #include <linux/module.h>
 11 #include <net/sock.h>
 12 #include "../br_private.h"
 13 #include <linux/netfilter.h>
 14 #include <linux/netfilter/x_tables.h>
 15 #include <linux/netfilter_bridge/ebtables.h>
 16 #include <linux/netfilter_bridge/ebt_redirect.h>
 17 
 18 static unsigned int
 19 ebt_redirect_tg(struct sk_buff *skb, const struct xt_action_param *par)
 20 {
 21         const struct ebt_redirect_info *info = par->targinfo;
 22 
 23         if (!skb_make_writable(skb, 0))
 24                 return EBT_DROP;
 25 
 26         if (par->hooknum != NF_BR_BROUTING)
 27                 /* rcu_read_lock()ed by nf_hook_slow */
 28                 ether_addr_copy(eth_hdr(skb)->h_dest,
 29                                 br_port_get_rcu(par->in)->br->dev->dev_addr);
 30         else
 31                 ether_addr_copy(eth_hdr(skb)->h_dest, par->in->dev_addr);
 32         skb->pkt_type = PACKET_HOST;
 33         return info->target;
 34 }
 35 
 36 static int ebt_redirect_tg_check(const struct xt_tgchk_param *par)
 37 {
 38         const struct ebt_redirect_info *info = par->targinfo;
 39         unsigned int hook_mask;
 40 
 41         if (BASE_CHAIN && info->target == EBT_RETURN)
 42                 return -EINVAL;
 43 
 44         hook_mask = par->hook_mask & ~(1 << NF_BR_NUMHOOKS);
 45         if ((strcmp(par->table, "nat") != 0 ||
 46             hook_mask & ~(1 << NF_BR_PRE_ROUTING)) &&
 47             (strcmp(par->table, "broute") != 0 ||
 48             hook_mask & ~(1 << NF_BR_BROUTING)))
 49                 return -EINVAL;
 50         if (INVALID_TARGET)
 51                 return -EINVAL;
 52         return 0;
 53 }
 54 
 55 static struct xt_target ebt_redirect_tg_reg __read_mostly = {
 56         .name           = "redirect",
 57         .revision       = 0,
 58         .family         = NFPROTO_BRIDGE,
 59         .hooks          = (1 << NF_BR_NUMHOOKS) | (1 << NF_BR_PRE_ROUTING) |
 60                           (1 << NF_BR_BROUTING),
 61         .target         = ebt_redirect_tg,
 62         .checkentry     = ebt_redirect_tg_check,
 63         .targetsize     = sizeof(struct ebt_redirect_info),
 64         .me             = THIS_MODULE,
 65 };
 66 
 67 static int __init ebt_redirect_init(void)
 68 {
 69         return xt_register_target(&ebt_redirect_tg_reg);
 70 }
 71 
 72 static void __exit ebt_redirect_fini(void)
 73 {
 74         xt_unregister_target(&ebt_redirect_tg_reg);
 75 }
 76 
 77 module_init(ebt_redirect_init);
 78 module_exit(ebt_redirect_fini);
 79 MODULE_DESCRIPTION("Ebtables: Packet redirection to localhost");
 80 MODULE_LICENSE("GPL");
 81 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp