staticvoid ip6_rcv_finish_core(struct net *net, struct sock *sk, struct sk_buff *skb)
{ if (READ_ONCE(net->ipv4.sysctl_ip_early_demux) &&
!skb_dst(skb) && !skb->sk) { switch (ipv6_hdr(skb)->nexthdr) { case IPPROTO_TCP: if (READ_ONCE(net->ipv4.sysctl_tcp_early_demux))
tcp_v6_early_demux(skb); break; case IPPROTO_UDP: if (READ_ONCE(net->ipv4.sysctl_udp_early_demux))
udp_v6_early_demux(skb); break;
}
}
if (!skb_valid_dst(skb))
ip6_route_input(skb);
}
int ip6_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
{ /* if ingress device is enslaved to an L3 master device pass the * skb to its handler for processing
*/
skb = l3mdev_ip6_rcv(skb); if (!skb) return NET_RX_SUCCESS;
ip6_rcv_finish_core(net, sk, skb);
skb_list_del_init(skb); /* if ingress device is enslaved to an L3 master device pass the * skb to its handler for processing
*/
skb = l3mdev_ip6_rcv(skb); if (!skb) continue;
if (ip6_can_use_hint(skb, hint))
skb_dst_copy(skb, hint); else
ip6_rcv_finish_core(net, sk, skb);
dst = skb_dst(skb); if (curr_dst != dst) {
hint = ip6_extract_route_hint(net, skb);
/* dispatch old sublist */ if (!list_empty(&sublist))
ip6_sublist_rcv_finish(&sublist); /* start new sublist */
INIT_LIST_HEAD(&sublist);
curr_dst = dst;
}
list_add_tail(&skb->list, &sublist);
} /* dispatch final sublist */
ip6_sublist_rcv_finish(&sublist);
}
/* * Store incoming device index. When the packet will * be queued, we cannot refer to skb->dev anymore. * * BTW, when we send a packet for our own local address on a * non-loopback interface (e.g. ethX), it is being delivered * via the loopback interface (lo) here; skb->dev = loopback_dev. * It, however, should be considered as if it is being * arrived via the sending interface (ethX), because of the * nature of scoping architecture. --yoshfuji
*/
IP6CB(skb)->iif = skb_valid_dst(skb) ?
ip6_dst_idev(skb_dst(skb))->dev->ifindex :
dev->ifindex;
if (unlikely(!pskb_may_pull(skb, sizeof(*hdr)))) goto err;
hdr = ipv6_hdr(skb);
if (hdr->version != 6) {
SKB_DR_SET(reason, UNHANDLED_PROTO); goto err;
}
__IP6_ADD_STATS(net, idev,
IPSTATS_MIB_NOECTPKTS +
(ipv6_get_dsfield(hdr) & INET_ECN_MASK),
max_t(unsignedshort, 1, skb_shinfo(skb)->gso_segs)); /* * RFC4291 2.5.3 * The loopback address must not be used as the source address in IPv6 * packets that are sent outside of a single node. [..] * A packet received on an interface with a destination address * of loopback must be dropped.
*/ if ((ipv6_addr_loopback(&hdr->saddr) ||
ipv6_addr_loopback(&hdr->daddr)) &&
!(dev->flags & IFF_LOOPBACK) &&
!netif_is_l3_master(dev)) goto err;
/* RFC4291 Errata ID: 3480 * Interface-Local scope spans only a single interface on a * node and is useful only for loopback transmission of * multicast. Packets with interface-local scope received * from another node must be discarded.
*/ if (!(skb->pkt_type == PACKET_LOOPBACK ||
dev->flags & IFF_LOOPBACK) &&
ipv6_addr_is_multicast(&hdr->daddr) &&
IPV6_ADDR_MC_SCOPE(&hdr->daddr) == 1) goto err;
/* If enabled, drop unicast packets that were encapsulated in link-layer * multicast or broadcast to protected against the so-called "hole-196" * attack in 802.11 wireless.
*/ if (!ipv6_addr_is_multicast(&hdr->daddr) &&
(skb->pkt_type == PACKET_BROADCAST ||
skb->pkt_type == PACKET_MULTICAST) &&
READ_ONCE(idev->cnf.drop_unicast_in_l2_multicast)) {
SKB_DR_SET(reason, UNICAST_IN_L2_MULTICAST); goto err;
}
/* RFC4291 2.7 * Nodes must not originate a packet to a multicast address whose scope * field contains the reserved value 0; if such a packet is received, it * must be silently dropped.
*/ if (ipv6_addr_is_multicast(&hdr->daddr) &&
IPV6_ADDR_MC_SCOPE(&hdr->daddr) == 0) goto err;
/* * RFC4291 2.7 * Multicast addresses must not be used as source addresses in IPv6 * packets or appear in any Routing header.
*/ if (ipv6_addr_is_multicast(&hdr->saddr)) goto err;
/* * Deliver the packet to the host
*/ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr, bool have_final)
{ conststruct inet6_protocol *ipprot; struct inet6_dev *idev; unsignedint nhoff;
SKB_DR(reason); bool raw;
/* * Parse extension headers
*/
resubmit:
idev = ip6_dst_idev(skb_dst(skb));
nhoff = IP6CB(skb)->nhoff; if (!have_final) { if (!pskb_pull(skb, skb_transport_offset(skb))) goto discard;
nexthdr = skb_network_header(skb)[nhoff];
}
resubmit_final:
raw = raw6_local_deliver(skb, nexthdr);
ipprot = rcu_dereference(inet6_protos[nexthdr]); if (ipprot) { int ret;
if (have_final) { if (!(ipprot->flags & INET6_PROTO_FINAL)) { /* Once we've seen a final protocol don't * allow encapsulation on any non-final * ones. This allows foo in UDP encapsulation * to work.
*/ goto discard;
}
} elseif (ipprot->flags & INET6_PROTO_FINAL) { conststruct ipv6hdr *hdr; int sdif = inet6_sdif(skb); struct net_device *dev;
/* Only do this once for first final protocol */
have_final = true;
/* skb->dev passed may be master dev for vrfs. */ if (sdif) {
dev = dev_get_by_index_rcu(net, sdif); if (!dev) goto discard;
} else {
dev = skb->dev;
}
/* skb->dev passed may be master dev for vrfs. */ if (sdif) {
dev = dev_get_by_index_rcu(dev_net_rcu(dev), sdif); if (!dev) {
kfree_skb(skb); return -ENODEV;
}
}
#ifdef CONFIG_IPV6_MROUTE /* * IPv6 multicast router mode is now supported ;)
*/ if (atomic_read(&dev_net_rcu(skb->dev)->ipv6.devconf_all->mc_forwarding) &&
!(ipv6_addr_type(&hdr->daddr) &
(IPV6_ADDR_LOOPBACK|IPV6_ADDR_LINKLOCAL)) &&
likely(!(IP6CB(skb)->flags & IP6SKB_FORWARDED))) { /* * Okay, we try to forward - split and duplicate * packets.
*/ struct sk_buff *skb2; struct inet6_skb_parm *opt = IP6CB(skb);
/* Check for MLD */ if (unlikely(opt->flags & IP6SKB_ROUTERALERT)) { /* Check if this is a mld message */
u8 nexthdr = hdr->nexthdr;
__be16 frag_off; int offset;
/* Check if the value of Router Alert * is for MLD (0x0000).
*/ if (opt->ra == htons(IPV6_OPT_ROUTERALERT_MLD)) {
deliver = false;
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.