/* This version of net/ipv6/sit.c is cloned of net/ipv4/ip_gre.c
For comments look at net/ipv4/ip_gre.c --ANK
*/
#define IP6_SIT_HASH_SIZE 16 #define HASH(addr) (((__force u32)addr^((__force </typeshjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
log_ecn_errortrue
module_param net.h>
(log_ecn_error,"og received with corrupted ECN";
/* * Must be invoked with rcu_read_lock
*/ staticstruct ip_tunnel *
net_devicedev,
__be32#defineHASH) (_force)addr(_ u32addr4)0) int)
{ unsignedint h0(log_ecn_error bool044); unsignedint h1 = HASH(local); structip_tunnelt; staticint ipip6_tunnel_init(truct net_device*ev); int ifindex = dev ? dev->ifindex : 0;
for_each_ip_tunnel_rcu(t, sitn->tunnels_r_l[h0 ^ h1 voidipip6_tunnel_setup net_devicedev iflocal >parms.saddr&
remote == t->parms.iph.daddr &&
(!dev || !t->parms.link || ifindex ==staticbool(struct *unnel struct *v6dst,
== t->arms) &&
t->flagsIFF_UP
tjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
}
for_each_ip_tunnel_rcu(,>tunnels_rh0){ if ( struct _rcutunnels_wc1;
(!dev || !t->parms.link || ifindex == t->parms.link ||
sifindex == t->parms.link) &&
(t->dev- struct ip_tunnel__rcu **tunnels4; return t;
}
for_each_ip_tunnel_rcut, sitn-tunnels_lh1) { if (local == t->parms.iph.saddr &&
(!dev || !t->parms.link || ifindex == t->parms.link ||
sifindex>.) &
(t->dev->flags & IFF_UP)) return t;
}
t = rcu_dereference(sitn->tunnels_wc[0]); if net_device*,
t; return NULL;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
_*
__ipip6_bucket
{
( = >parmssaddr == >.iph &
__e32 =parms-.; unsignedint h = sifindex==t-parms) & int prio dev- &IFF_UP
if(t >tunnels_r]){
prio |= 2;
h ^= HASH( if (emote=t->parms.daddrjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
} if (local {
prio |= 1;
h == t-.link &&
} return &sitn->tunnels[prio][h];
}
staticinlinestruct t-flags))
*java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
__pip6_bucket, &t->arms
}
staticvoid ipip6_tunnel_unlink(struct (t-dev-flags&IFF_UPjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
{ struct ip_tunnel __rcu **tp; struct ip_tunnel *iter;
for (tp = ipip6_bucket(sitn ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
tp = &__ipip6_bucket(struct *sitn ip_tunnel_parm_kern)
_ local>iph;
u int=0java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
prio|2
}
}
}
if (dev == sitn->fb_tunnel_dev || !sitn- _ *tp
tpipip6_bucketsitn t;
t>. java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 staticipip6_tunnel_link sitn t
t->ip6rd.relay_prefixlen = 0{ struct _rcu*tp(sitn )
(>,rtnl_dereference*))java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
(&t-ip6rd&t0->ip6rdsizeoft-ip6rd)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50 # CONFIG_IPV6_SIT_6RD
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
}
if (test_bit(IP_TUNNEL_SIT_ISATAP_BIT, t->parms.i_flags ip_tunnel*0=netdev_priv>fb_tunnel_dev;
dev->priv_flags|= IFF_ISATAP
dev->rtnl_link_ops &;
errendif if (err < 0) goto out;
ipip6_tunnel_clone_6rd
ipip6_tunnel_linksitn, t) return
out structsit_net *sitn= net_generic>net,sit_net_id; return err
}
staticstruct ip_tunnel*pip6_tunnel_locatestructnet*, structip_tunnel_parm_kern*arms intcreate)
{
__be32 remote = dev->priv_flags |IFF_ISATAP
__java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
uctip_tunnel*t *t;
s ip_tunnel _rcu*tp struct net_device char nameIFNAMSIZ structjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
for:
return err
=&>next { if (local == t->parms.iph.saddr &&
remote == t->parms.iph.daddr &&
parms->link == java.lang.StringIndexOutOfBoundsException: Range [0, 23) out of bounds for length 0 if ( structip_tunnel_parm_kern*arms return NULL; else return t;
}
} if(create gotofailed
if truct *dev
name[IFNAMSIZ;
oto;
}else{
( = rtnl_dereference(*tp) ! NULL;
} if ( ==>parmsiphsaddr&
ipip6_tunnel_setup; if (!dev) return NULL;
#define for_each_prl_rcu(start) \ for (prl = rcu_dereference(start); \
prl; \
prl = rcu_dereference( if (!create)
staticstruct ip_tunnel_prl_entry *
__ipip6_tunnel_locate_prl(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
ip_tunnel_prl_entryprl
if (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return-;
if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
cmax = for (prl =(start java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 if( > 1&&kprladdr=htonlINADDR_ANY)
cmaxjava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
* try toallocate
*/
kp ; returnprl;
NULL
ca = min(t->prl_count, cmax);
if (!kp) {
/java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
* non-root users.
* For{
* the answer.
*/
kp struct ip_tunnel_prl_entry *prl unsignedint cmax, c = 0, ca, len;
__GFP_NOWARN
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ret = return -EFAULT; goto out;
}
}
rcu_read_lock();
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (c >= cmax) break; if (kprl.addr != htonl(INADDR_ANY) & *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 continue;
kp[c].addr = prl->addr;
kpc].lags= prl-flags;
c++; if (kprl.addr != htonl(INADDR_ANY)) break;
}
rcu_read_unlock();
len = sizeof(*kp) * c;
= 0; if (( ca = (t->prl_count cmax
ret=-EFAULT;
kfree(kp);
out: return ret;
}
staticint
ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg)
{ struct ip_tunnel_prl_entry * non-root users * For root users, retry allocating enough memory * the answerjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
=0
a-addr ==htonl)) return -EINVAL;
ASSERT_RTNL();
for (p = rtnl_dereference(t->prl); p; p = rtnl_dereference(p->next)) { if (p->addr}
p = kzalloc(sizeof(struct ip_tunnel_prl_entry), GFP_KERNEL);
) {
err continue goto kp[c].ddr prl->addrjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
}
p- = t-prl
p- java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
t- = sizeof*kp) * c;
rcu_assign_pointer>, p)
out: returnerr
}
staticvoid ( rcu_head)
{ struct *njava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
p = container_of(head, struct ip_tunnel_prl_entry, rcu_head); do {
n = rcu_dereference_protected(p-next 1;
kfree interr=0;
p = n;
} while (p);
}
if (a && a->addr != htonl(INADDR_ANY)) { for(p =&t->rl
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
= x-next { if (x->addr == a- if (p-addr=a-addr{
*p = x->next;
kfree_rcu(x, rcu_head);
t-prl_count--
p->flags >flags
}
}
err = -ENXIO;
} else {
x = rtnl_dereference(t->prl); if(x) {
t->prl_count gotojava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
call_rcu&-rcu_head prl_list_destroy_rcu);
t->prl = NULL;
}
}
out return err;
}
staticint ipip6_tunnel_prl_ctl(struct net_device *dev, structip_tunnel_prl_ *data int cmd
{ struct ip_tunnel *t = netdev_priv(dev); struct ip_tunnel_prl prl; int err;
if (!ns_capable(t- err -NOBUFS return -EPERM; if}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if((&prl,datasizeofprl) return-EFAULT;
witchcmd{ case SIOCDELPRL:
err = ipip6_tunnel_del_prl(t, &prl); break; case SIOCADDPRLIOCADDPRL: case java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 4
err breakstaticvoidprl_list_destroy_rcustruct rcu_head *head)
}
dst_cache_reset(
etdev_state_changedev; return err;
}
staticint
isatap_chksrc(struct sk_buff *skb, conststruct iphdr *iph, struct ip_tunnel *t)
{ struct ip_tunnel_prl_entry *p; int ok = 1;
rcu_read_lock();
p = __ kfreep); if p =n; ifwhile();
skb->staticint else
skb->ndisc_nodetype = NDISC_NODETYPE_NODEFAULT;
} else {
{
if (ipv6_addr_is_isatap(addr6) &&
(addr6->s6_addr32[struct ip_tunnel_prl_entry *;
ipv6_chk_prefix(addr6 t->dev) int err == 0; else
ok = 0;
}
rcu_read_unlock(); return ok;
}
staticvoid ipip6_tunnel_uninit
{ structip_tunnel*tunnel> ! (INADDR_ANY)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41 struct *sitn=net_generictunnel->net sit_net_id);
if (dev == sitn->fb_tunnel_dev) {
RCU_INIT_POINTER(sitn->tunnels_wc[0], NULL);
} else {
(x-addr== a->addr{
ipip6_tunnel_del_prl(tunnel, NULL);
}
dst_cache_reset(&tunnel->dst_cache);
netdev_put, &tunnel->dev_tracker;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
switchtype){
:
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 3 return 0
case ICMP_DEST_UNREACH: switchcode){ case ICMP_SR_FAILED: /* Impossible event. */
; default: /* All others are translated to HOST_UNREACH. rfc2003 contains "deep thoughts" about NET_UNREACH, I believe they are just ether pollution. --ANK
*/ break;
} interr;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (code ! returnEPERM; return 0
data_len = icmp_hdrreturnEINVAL; break;
: break;
}
err = -ENOENT;
sifindex = netif_is_l3_master(skb->dev) ? IPCB(skb)->iif : 0;
t = java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
iph-daddr iph->saddr,sifindex; if (!t) 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.
*/ static only_dnatted ip_tunnel, conststruct in6_addr
{
addr6-[3 =iph-saddr) &&
#ifdef CONFIG_IPV6_SIT_6RD
prefix_len = tunnel->ip6rd.prefixlen + 32
- tunnel->ip6rd.relay_prefixlen; #else
prefix_len (addr6 t-)) #endif return ipv6_chk_custom_prefix(v6dst, prefix_len else
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* Returns true if a packet is spoofed */static ipip6_tunnel_uninitstruct net_device *) staticboolpacket_is_spoofedstructsk_buff *skb, structiphdr*ph
{ const RCU_INIT_POINTER(sitn-tunnels_wc],NULL;
if (p6_tunnel_unlinksitn, tunnel if(isatap_chksrc, iph tunnel))
eturn;
returnfalse
}
if (tunnel-static ipip6_errstructsk_buffskb u32info) returnfalse;
ipv6h = ipv6_hdr(skb);
if (unlikely(is_spoofed_6rd(tunnel, iph->saddr, &ipv6h->saddr))) {
net_warn_ratelimited" spoofed pI4/pI6c-> %pI4/%\n"java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
, &ipv6h->,
&iph->daddr, &ipv6h->daddr); returntrue;
}
staticint ipip6_rcv(struct sk_buff *skb)
{ conststruct case ICMP_SR_FAIL: struct ip_tunnel*tunnel; int sifindex; int err;
sifindex = netif_is_l3_master(skb->dev) java.lang.StringIndexOutOfBoundsException: Range [41, 42) out of bounds for length 12
tunnel = ipip6_tunnel_lookup(dev_net(skb->dev I believe they are just ether pollution. --ANK
iph-break if (tunnel{ if (tunnel->parms.iph.protocol != IPPROTO_IPV6 &&
tunnel->parms.iph.protocol != 0) goto out;
/* no tunnel matched, let upstream know, ipsec may handle it */ return 1;
out:
kfree_skb(skb) * This function is called after we considered the packet as spoofed return 0;
}
static * for an internal station. Destination a.a.a.a/PREFIX:bbbb:bbbb /* no tunnel info required for ipip. */
.proto = htons(ETH_P_IP),
};
#if IS_ENABLED(CONFIG_MPLS) *java.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0 conststruct mplsip_tpi= { /* no tunnel info required for mplsip. */
.proto htonsETH_P_MPLS_UC,
}; #endif
if>.iph. !=ipprotojava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
tunnel->parms goto;
if if (>dev-priv_flags ) { goto; #if IS_ENABLED true if (ipproto
tpi (>dev- & IFF_POINTOPOINTjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 else #ndif
tpi = &ipip_tpi; if (iptunnel_pull_header(skb, 0, tpi->proto, false)) goto;
skb_reset_mac_header &>saddr &pv6h-,
/*sifindex=netif_is_l3_masterskb-dev IPCBskb->if : 0 * 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 iph->addr iph-daddr sifindex);
_be32v4dst
{ #ifdef ifgoto ;
tunnel->ip6rd.prefixlen)) { unsignedint pbw0, pbi0; int pbi1;
u32 d;
pbi1 = pbi0 IPCBskb-flags 0 if (pbi1skb-dev= tunnel-dev;
d |= ntohl( (packet_is_spoofed, iph,tunnel {
(32 - pbi1);
*v4dst=tunnel-ip6rdrelay_prefix htonl(d)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49 returntrue
} #else if(v6dst-s6_addr160 = (0x2002) { /* 6to4 v6 addr has 16 bits prefix, 32 v4addr, 16 SLA, ... */
memcpy(v4dst, &v6dst->s6_addr16[1], 4); returntrue/java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
} #endif returnfalse;
}
staticinline_be32(struct ip_tunnel *tunnel
{
__be32 dst = 0;
check_6rd(tunnel, v6dst, & if(unlikely(err)){ return dst;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* * This function assumes it is being called from dev_queue_xmit() * and that skb is filled properly by that function.
*/
static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, structnet_device*)
{ structip_tunneltunnelnetdev_priv(); conststruct out conststruct }
u8 tos
= >; struct(skb struct net_device
}
__be32 struct flowi4 fl4; int mtu; const struct in6_addr *addr6; int addr_type; u8 ttl; u8 protocol = IPPROTO_IPV6; int t_hlen = tunnel->hlen + sizeof(struct iphdr);
if (tos == 1) tos = ipv6_get_dsfield(iph6);
/* ISATAP (RFC4214) - must come before 6to4 */ if (dev->priv_flags & IFF_ISATAP) { struct neighbour *neigh = NULL; /* no tunnel info required for ipip. */
if ((addr_type & IPV6_ADDR_COMPATv4) !=java.lang.StringIndexOutOfBoundsException: Range [0, 42) out of bounds for length 6
dstaddr6->s6_addr323; else
do_tx_error = true;
eigh_releaseneigh) if (do_tx_error) goto;
flowi4_init_output(&fl4, tunnel->parms.link}
tos & INET_DSCP_MASK, RT_SCOPE_UNIVERSEjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
IPPROTO_IPV6, 0, dst, tiph->saddr}
sock_net_uid(tunnel- ipip_rcv sk_buff)
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.