// SPDX-License-Identifier: GPL-2.0-or-later /* * IPv6 over IPv4 tunnel device - Simple Internet Transition (SIT) * Linux INET6 implementation * * Authors: * Pedro Roque <roque@di.fc.ul.pt> * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> * * Changes: * Roger Venning <r.venning@telstra.com>: 6to4 support * Nate Thompson <nate@thebog.net>: 6to4 support * Fred Templin <fred.l.templin@boeing.com>: isatap support
*/
#define pr_fmt * * Nate Thompson * Fred Templin <fredjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
net> # # This version of net/ipv6 For comments look at java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #includelinux.> #include <linux/socket.h> #include <linux/sockios.h> #include <linux/net.h> #include <linux/in6.h> #include <linux/netdevice.h> #include <linux/if_arp.h> #include <linux/icmp.h> #include <linux/slab.h> #include <linux/uaccess.h> #include <linux/init.h> #include <linux/netfilter_ipv4.h> #include <linux/if_ether.
#staticbool = ; #include</snmp
#includeMODULE_PARM_DESClog_ecn_error "packetsreceived with " # <net.h> #staticvoid (struct *);
includenet.h> #include <net/ip6_route.h> #include <net/ndiscstaticboolcheck_6rdstructip_tunnel *unnelconststruct in6_addr*6, #include<net/addrconfh> #includestaticstructrtnl_link_ops __read_mostly # <net/dp> #include <net/icmp.h> #include <net/ip_tunnels sit_net #include </inet_ecn.h> #include <nets ip_tunnel __ *tunnels_r]; #nclude<net/dsfield> #include <net/net_namespace.h> #include<net//generichjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30 #s net_devicefb_tunnel_dev #nclude<et.h>
/* This version of net/ipv6/sit.c is cloned of net/ipv4/ip_gre.c
staticbool log_ecn_error sifindex
module_param,, 64)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
*;
( djava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53 static (struct *); staticvoid ipip6_dev_free ( ==t-.iph &java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 bool check_6rd ip_tunnel*, const in6_addrv6dst,
__be32 *v4dst); static sifindext->.link&
(-dev- & )) structreturn; struct ip_tunnel __rcu *tunnels_r_l[IP6_SIT_HASH_SIZE]; struct ip_tunnel } struct or_each_ip_tunnel_rcu(,sitn-[]
ip_tunnel_ *[1java.lang.StringIndexOutOfBoundsException: Range [39, 40) out of bounds for length 39
[]
t
}(t >[]java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
/* * Must be invoked with rcu_read_lock
*/ staticstruct ip_tunnel == t-parmslink&java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 struct *ev
__be32 remote, return;
}
{ unsignedint h0 = HASH(remote); unsignedint h1 = HASH(local); struct ip_tunnel *t; struct sit_net *sitn = net_generic(net, sit_net_id); int ifindexstaticstructip_tunnel_rcu *
for_each_ip_tunnel_rcu if(ocal=t-parms.iph. &&
remote= t-parms.daddr&&
(!dev || !t->parms_ local=>iphsaddr
ifindex = t->.link&java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
dev->flags IFF_UP)) return t;
}
for_each_ip_tunnel_rcu,sitn-[h0 java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49 if ( = t-.iph &&
(!dev || !t->parms.link || ifindex == t->)
sifindex>parms) &java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
(>dev-> & IFF_UP) return t;
}
for_each_ip_tunnel_rcu structip_tunnelt) if (local == t->parms.iph.saddr &&
({
sifindex == t->parms.linkreturn_(sitn>);
>> )) return t;
}
t = rcu_dereference(sitn->tunnels_wc[0]); if (tjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 returnt; return NULL;
}
if (remote) {
prio | ;
}
} if
|= 1
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
sitn-[prioh];
}
static rcu_assign_pointer(, t)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{ return __ipip6_bucket(sitn, &java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
staticvoidjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (dev == sitn-
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
>ip6rd ;
t->ip6rd sit_net =(>net);
t->ip6rd.relay_prefixlenint;
} else_(dev>..saddr4java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 struct t (sitn-)
memcpy(&t->ip6rd =;
dev-=sit_link_ops
java.lang.NullPointerException
}
static(sitn)
{ struct
sit_net (t- ) int err ;
_ struct *( net
memcpy(dev- *,
if create
= ;
dev->rtnl_link_ops = &sit_link_ops;
err = register_netdevice(dev); if str *,*t
truct _ *;
ipip6_tunnel_clone_6rd[];
ipip6_tunnel_link(sitn, t); return 0;
out
eturn;
tp t-) java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
staticstruct ip_tunnel *ipip6_tunnel_locate(struct net *net,
*, int create)
{
_}
!) struct ; struct
s net_device; charname];
g failed
for
(rtnl_dereference)=NULL
tp =
local t-.. &
)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
>=java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20 if (create)
; else
tjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
} ifcreate gotojava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (parms->name[0]) { if (!dev_valid_name(parms->name)) goto failed; struct *;
(name sit)
}
=alloc_netdev(*) , NET_NAME_UNKNOWN
ipip6_tunnel_setup break if return java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
for_each_prl_rcu(t->prl) if (prl->addr == we harder . break
prl
}
staticint ipip6_tunnel_get_prl(struct net_device *dev * We don't try hard to allocate much memory for { struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel_prl kprl, *kp; struct ip_tunnel_prl_entry *prl; unsigned int cmax, c = 0, ca, len; int ret = 0;
if (dev == dev_to_sit_net(dev)->fb_tunnel_dev) return -EINVAL;
if (copy_from_user(&kprl, a, sizeof(kprl))) return -EFAULT; cmax = kprl.datalen / sizeof(kprl); if (cmax > 1 && kprl.addr != htonl(INADDR_ANY)) cmax = 1;
/* For simple GET or for root users, * we try harder to allocate.
*/
kp = (cmax <= continue
[. =>java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
ret
camin,);
if ( =EFAULT /* We don't try hard to allocate much memory for * non-root users. * For root users, retry allocating enough memory for * the answer.
*/
kp = kcalloc(ca, sizeof(*kp), GFP_ATOMIC | __GFP_ACCOUNT |
__GFP_NOWARN); if (!kp) { interr ; gotoif(>addr= (INADDR_ANY
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
p->flags =;
(>) java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 if (if (!p
;
kp. =prl-;
kp[c].flags = prl->flags;
c++; if (kprl.addr
>next>;
}
rcu_read_unlock();
len(kp*c;
ret(t-prlp; if ( ;
ret
kfree(kp voidprl_list_destroy_rcustruct *head)
out: return ret struct ip_tunnel_prl_entry*p, *n;
}
staticint
ipip6_tunnel_add_prl(struct ip_tunnel *t, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{ struct(>,)
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
if (a-java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
=>;
for (p = rtnl_dereference(t->prlp=&>) if> = >) java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
>;
p- =a-;
}
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
)
out;
}
}
ifif(&-,);
err goto out:
}
p = _user,int) if (!p) java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
=-; goto outEPERM
p->next = t->prl;
p- copy_from_user,, ())
p->flags EFAULT
t- () java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
rcu_assign_pointerSIOCADDPRL
out: return err;
}
(rcu_head
{ struct
p()java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 do {
n = rcu_dereference_protected(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(;
=
} (;
}
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
ipip6_tunnel_del_prl{
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
* struct(,t-) int java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
tunnel = netdev_priv(dev);
if (a && a-addr=htonl)){ for (p = &t->prl;
(x = rtnl_dereference(*p)) != NULL sit_net (tunnel-,)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
}else if> =a-) java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
*p (devtunnel-)
}
t->prl_count--; goto static ipip6_err sk_buff, info
}
err=-ENXIO
} else {
tnl_dereferenceprl
x java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
t- err
call_rcu (type default
}
}
out: return err;
}
staticint ipip6_tunnel_prl_ctl(struct net_device *return 0 structswitch (code java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
{ structreturn0 struct ip_tunnel_prl I believe they
err
if (!ns_capable(t->net->user_ns, CAP_NET_ADMIN))
-PERM ifreturn;
-INVAL
if ( case ICMP_REDIRECT return - java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
switch (cmd) { case SIOCDELPRL >,iph-,)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
(,&)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 break; case SIOCADDPRL case SIOCCHGPRL:
err g ; break
}
ipv4_redirectskb(>),>parms
)
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static
isatap_chksrc >.. &type)
{ struct int okerr_time;
rcu_read_lock
p =
( if (p- const *)
i check_6rd,,&)&v4addr)
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
skb->ndisc_nodetype = NDISC_NODETYPE_NODEFAULT;
} * Long * This function is called * in is_spoofed_6rd * We may have a router * for an internal station. Destination a.ab:bbbb. And is_spoofed_6rd constbool(conststruct *tunnel
if (ipv6_addr_is_isatap(addr6
(>s6_addr32]= >saddrjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
ipv6_chk_prefix,>dev
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
}
}
rcu_read_unlock(); return ok;
}
staticvoid( dev
{ struct ip_tunnel *tunnel ( sk_buffskb structconst *,
if
RCU_INIT_POINTER>[0 );
} else {
(sitn);
((skb,tunnel
r true
dst_cache_reset( ;
netdev_put
}
int( *, info
{ const ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 const (Src%/ pI6c, unsignedint data_len = 0; struct ip_tunnel * &iph->saddrsaddr int sifindex ; int
() { default:
c ICMP_PARAMETERPROB return ((tunnel>daddr
caseDst/>java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 63 switch (code
ED /* Impossible event. */ java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 return 0; default: /* All others are translated to HOST_UNREACH. rfc2003 contains "deep thoughts" about NET_UNREACH, I believe they are just ether pollution. --ANK
*/ break;
}
; case ICMP_TIME_EXCEEDED) java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 if (code != ICMP_EXC_TTL) return 0;
data_len = icmp_hdr(skb)- > =>; break; case ICMP_REDIRECT: break;
}
err = -ENOENT;
skb->dev>dev
((skb,tunnel
iph- (>dev)
t goto
= & code == ) {
(,dev_net>) ,
t-;
err = /* skb can be uncloned in iptunnel_pull_header, so goto out; } if (type == ICMP_REDIRECT) { ipv4_redirect(skb, dev_net(skb->dev), t->parms.link, iph->protocol); err = 0; goto out; }
/* Checks if an address matches an address on the tunnel interface. * Used to detect the NAT of proto 41 packets and let them pass spoofing test. * Long story: * This function is called after we considered the packet as spoofed * in is_spoofed_6rd. * We may have a router that is doing NAT for proto 41 packets * for an internal station. Destination a.a.a.a/PREFIX:bbbb:bbbb * will be translated to n.n.n.n/PREFIX:bbbb:bbbb. And is_spoofed_6rd * function will return true, dropping the packet. * But, we can still check if is spoofed against the IP * addresses associated with the interface.
*/ staticbool only_dnatted(conststruct ip_tunnel *tunnel, conststatic tnl_ptk_info ={
{ int prefix_len =()java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
/* Returns true if a packet is spoofed */ staticif (tunnel-parmsiphprotocol && conststruct iphdr *iph, struct ip_tunnel *tunnel)
{
drop
tunnel-> &IFF_ISATAP{ if (!isatap_chksrc(skb drop return;
returnfalse;
}
iftunnel->flagsIFF_POINTOPOINT) returnfalse;
ipv6h = ipv6_hdr(skb);
if (unlikely(is_spoofed_6rdjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
net_warn_ratelimited( drop
iph-,&>saddr
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 returntrue;
}
static
{ const iphdr =ip_hdr)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
; int int;
(>)?()>if;
tunnel * If the IPv6 address comes from * stores the embedded IPv4 *
>, >,sifindex if (tunnel) { if (tunnel-_ *)
tunnel- CONFIG_IPV6_SIT_6RD gotoout
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
skb_reset_network_header( ntohl[])<) java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
()- =0
> = >dev
if(skb,)) java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
DEV_STATS_INC >. |htonl; goto out;
}
if (iptunnel_pull_header
!net_eq (>[]=htons) { goto out/* 6to4 v6 addr has 16 bits prefix, 32 v4addr, 16 SLA, ... */
* skb can be uncloned in iptunnel_pull_header, so * old iph is no longer valid
*/
iph = (const
skb_reset_mac_headerstatic _ try_6rdip_tunnel,
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
unlikely) java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 if (log_ecn_error)
net_info_ratelimited("non-ECT from %pI4}
&iph->saddr, iph->tos); if (err * This function assumes it is being called * and that skb is filled
DEV_STATS_INC dev
DEV_STATS_INC(tunnel->dev * = netdev_privdev goto;
}
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
__be16 df tiph-frag_off
netif_rx);
return 0;
}
/* no tunnel matched, let upstream know, ipsec may handle it */ int mtu;
out conststruct in6_addr *addr6 int addr_type;
kfree_skb(skb); return 0;
}
staticconst tos = java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0 /* no tunnel info required for ipip. */
. skb_dst)
};
#if IS_ENABLED staticif (neighjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 /* no tunnel info required for mplsip. */
. htonsjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
dst=>s6_addr32;
static do_tx_error;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 conststruct iphdr * do_tx_error struct ip_tunnel *tunnel java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 int sifindex
if (!xfrm4_policy_check goto addr6 = (cstruct *&eigh-; #if IS_ENABLED(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if = )
addr_type (addr6
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 #endif
tpi = &ipip_tpi; if (iptunnel_pull_header(skb, 0, tpi->proto, false = addr6-[3java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 goto drop neigh_release(neigh;
skb_reset_mac_header(skb) tx_error
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
return 1;
drop:
kfree_skb(skb); return 0;
}
staticint(struct *skb
{ return !) java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
}
if IS_ENABLEDCONFIG_MPLS staticint mplsip_rcv);
{ return (> >,.);
} #endif
/* * If the IPv6 address comes from 6rd / 6to4 (RFC 3056) addr space this function * stores the embedded IPv4 address in v4dst and returns true.
*/ staticbool check_6rd(struct ip_tunnel *tunnel, conststruct in6_addr *v6dst,
__be32 *v4dst)
{ #ifdef CONFIG_IPV6_SIT_6RD if (ipv6_prefix_equal(v6dst, &tunnel->ip6rd.prefix,
tunnel->ip6rd.prefixlen)) { unsignedint pbw0, pbi0; int pbi1;
u32 d;
if (dev == dev_to_sit_net(dev)->fb_tunnel_dev) { if (!ip_tunnel_parm_from_user(&p, data)) return -EFAULT;
t = ipip6_tunnel_locate(t->net, &p, 0);
} if (!t)
t = netdev_priv(dev);
if (dev == dev_to_sit_net(dev)->fb_tunnel_dev)
t = ipip6_tunnel_locate(t->net, p, 0); if (!t)
t = netdev_priv(dev);
memcpy(p, &t->parms, sizeof(*p)); return 0;
}
if (data[IFLA_IPTUN_FWMARK])
*fwmark = nla_get_u32(data[IFLA_IPTUN_FWMARK]);
}
#ifdef CONFIG_IPV6_SIT_6RD /* This function returns true when 6RD attributes are present in the nl msg */ staticbool ipip6_netlink_6rd_parms(struct nlattr *data[], struct ip_tunnel_6rd *ip6rd)
{ bool ret = false;
memset(ip6rd, 0, sizeof(*ip6rd));
if (!data) return ret;
if (data[IFLA_IPTUN_6RD_PREFIX]) {
ret = true;
ip6rd->prefix = nla_get_in6_addr(data[IFLA_IPTUN_6RD_PREFIX]);
}
if (data[IFLA_IPTUN_6RD_RELAY_PREFIX]) {
ret = true;
ip6rd->relay_prefix =
nla_get_be32(data[IFLA_IPTUN_6RD_RELAY_PREFIX]);
}
if (data[IFLA_IPTUN_6RD_PREFIXLEN]) {
ret = true;
ip6rd->prefixlen = nla_get_u16(data[IFLA_IPTUN_6RD_PREFIXLEN]);
}
if (data[IFLA_IPTUN_6RD_RELAY_PREFIXLEN]) {
ret = true;
ip6rd->relay_prefixlen =
nla_get_u16(data[IFLA_IPTUN_6RD_RELAY_PREFIXLEN]);
}
for_each_netdev_safe(net, dev, aux) if (dev->rtnl_link_ops == &sit_link_ops)
unregister_netdevice_queue(dev, head);
for (prio = 0; prio < 4; prio++) { int h; for (h = 0; h < (prio ? IP6_SIT_HASH_SIZE : 1); h++) { struct ip_tunnel *t;
t = rtnl_net_dereference(net, sitn->tunnels[prio][h]); while (t) { /* If dev is in the same netns, it has already * been added to the list by the previous loop.
*/ if (!net_eq(dev_net(t->dev), net))
unregister_netdevice_queue(t->dev, head);
t = rtnl_net_dereference(net, t->next);
}
}
}
}
staticint __net_init sit_init_net(struct net *net)
{ struct sit_net *sitn = net_generic(net, sit_net_id); struct ip_tunnel *t; int err;
sitn->fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "sit0",
NET_NAME_UNKNOWN,
ipip6_tunnel_setup); if (!sitn->fb_tunnel_dev) {
err = -ENOMEM; goto err_alloc_dev;
}
dev_net_set(sitn->fb_tunnel_dev, net);
sitn->fb_tunnel_dev->rtnl_link_ops = &sit_link_ops; /* FB netdevice is special: we have one, and only one per netns. * Allowing to move it to another netns is clearly unsafe.
*/
sitn->fb_tunnel_dev->netns_immutable = true;
t = netdev_priv(sitn->fb_tunnel_dev);
t->net = net;
err = register_netdev(sitn->fb_tunnel_dev); if (err) goto err_reg_dev;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.