Lines Matching refs:skb
142 static void vrf_tx_error(struct net_device *vrf_dev, struct sk_buff *skb) in vrf_tx_error() argument
145 kfree_skb(skb); in vrf_tx_error()
403 static int vrf_local_xmit(struct sk_buff *skb, struct net_device *dev, in vrf_local_xmit() argument
406 int len = skb->len; in vrf_local_xmit()
408 skb_orphan(skb); in vrf_local_xmit()
410 skb_dst_set(skb, dst); in vrf_local_xmit()
415 skb->pkt_type = PACKET_LOOPBACK; in vrf_local_xmit()
417 skb->protocol = eth_type_trans(skb, dev); in vrf_local_xmit()
419 if (likely(netif_rx(skb) == NET_RX_SUCCESS)) in vrf_local_xmit()
427 static void vrf_nf_set_untracked(struct sk_buff *skb) in vrf_nf_set_untracked() argument
429 if (skb_get_nfct(skb) == 0) in vrf_nf_set_untracked()
430 nf_ct_set(skb, NULL, IP_CT_UNTRACKED); in vrf_nf_set_untracked()
433 static void vrf_nf_reset_ct(struct sk_buff *skb) in vrf_nf_reset_ct() argument
435 if (skb_get_nfct(skb) == IP_CT_UNTRACKED) in vrf_nf_reset_ct()
436 nf_reset_ct(skb); in vrf_nf_reset_ct()
441 struct sk_buff *skb) in vrf_ip6_local_out() argument
445 vrf_nf_reset_ct(skb); in vrf_ip6_local_out()
448 sk, skb, NULL, skb_dst(skb)->dev, dst_output); in vrf_ip6_local_out()
451 err = dst_output(net, sk, skb); in vrf_ip6_local_out()
456 static netdev_tx_t vrf_process_v6_outbound(struct sk_buff *skb, in vrf_process_v6_outbound() argument
460 struct net *net = dev_net(skb->dev); in vrf_process_v6_outbound()
466 if (!pskb_may_pull(skb, ETH_HLEN + sizeof(struct ipv6hdr))) in vrf_process_v6_outbound()
469 iph = ipv6_hdr(skb); in vrf_process_v6_outbound()
478 fl6.flowi6_mark = skb->mark; in vrf_process_v6_outbound()
486 skb_dst_drop(skb); in vrf_process_v6_outbound()
493 return vrf_local_xmit(skb, dev, dst); in vrf_process_v6_outbound()
495 skb_dst_set(skb, dst); in vrf_process_v6_outbound()
498 __skb_pull(skb, skb_network_offset(skb)); in vrf_process_v6_outbound()
500 memset(IP6CB(skb), 0, sizeof(*IP6CB(skb))); in vrf_process_v6_outbound()
501 ret = vrf_ip6_local_out(net, skb->sk, skb); in vrf_process_v6_outbound()
509 vrf_tx_error(dev, skb); in vrf_process_v6_outbound()
513 static netdev_tx_t vrf_process_v6_outbound(struct sk_buff *skb, in vrf_process_v6_outbound() argument
516 vrf_tx_error(dev, skb); in vrf_process_v6_outbound()
523 struct sk_buff *skb) in vrf_ip_local_out() argument
527 vrf_nf_reset_ct(skb); in vrf_ip_local_out()
530 skb, NULL, skb_dst(skb)->dev, dst_output); in vrf_ip_local_out()
532 err = dst_output(net, sk, skb); in vrf_ip_local_out()
537 static netdev_tx_t vrf_process_v4_outbound(struct sk_buff *skb, in vrf_process_v4_outbound() argument
546 if (!pskb_may_pull(skb, ETH_HLEN + sizeof(struct iphdr))) in vrf_process_v4_outbound()
549 ip4h = ip_hdr(skb); in vrf_process_v4_outbound()
565 skb_dst_drop(skb); in vrf_process_v4_outbound()
572 return vrf_local_xmit(skb, vrf_dev, &rt->dst); in vrf_process_v4_outbound()
574 skb_dst_set(skb, &rt->dst); in vrf_process_v4_outbound()
577 __skb_pull(skb, skb_network_offset(skb)); in vrf_process_v4_outbound()
580 ip4h->saddr = inet_select_addr(skb_dst(skb)->dev, 0, in vrf_process_v4_outbound()
584 memset(IPCB(skb), 0, sizeof(*IPCB(skb))); in vrf_process_v4_outbound()
585 ret = vrf_ip_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb); in vrf_process_v4_outbound()
594 vrf_tx_error(vrf_dev, skb); in vrf_process_v4_outbound()
598 static netdev_tx_t is_ip_tx_frame(struct sk_buff *skb, struct net_device *dev) in is_ip_tx_frame() argument
600 switch (skb->protocol) { in is_ip_tx_frame()
602 return vrf_process_v4_outbound(skb, dev); in is_ip_tx_frame()
604 return vrf_process_v6_outbound(skb, dev); in is_ip_tx_frame()
606 vrf_tx_error(dev, skb); in is_ip_tx_frame()
611 static netdev_tx_t vrf_xmit(struct sk_buff *skb, struct net_device *dev) in vrf_xmit() argument
613 int len = skb->len; in vrf_xmit()
614 netdev_tx_t ret = is_ip_tx_frame(skb, dev); in vrf_xmit()
630 static void vrf_finish_direct(struct sk_buff *skb) in vrf_finish_direct() argument
632 struct net_device *vrf_dev = skb->dev; in vrf_finish_direct()
635 likely(skb_headroom(skb) >= ETH_HLEN)) { in vrf_finish_direct()
636 struct ethhdr *eth = skb_push(skb, ETH_HLEN); in vrf_finish_direct()
640 eth->h_proto = skb->protocol; in vrf_finish_direct()
643 dev_queue_xmit_nit(skb, vrf_dev); in vrf_finish_direct()
646 skb_pull(skb, ETH_HLEN); in vrf_finish_direct()
649 vrf_nf_reset_ct(skb); in vrf_finish_direct()
655 struct sk_buff *skb) in vrf_finish_output6() argument
657 struct dst_entry *dst = skb_dst(skb); in vrf_finish_output6()
663 vrf_nf_reset_ct(skb); in vrf_finish_output6()
665 skb->protocol = htons(ETH_P_IPV6); in vrf_finish_output6()
666 skb->dev = dev; in vrf_finish_output6()
669 nexthop = rt6_nexthop((struct rt6_info *)dst, &ipv6_hdr(skb)->daddr); in vrf_finish_output6()
674 sock_confirm_neigh(skb, neigh); in vrf_finish_output6()
675 ret = neigh_output(neigh, skb, false); in vrf_finish_output6()
683 kfree_skb(skb); in vrf_finish_output6()
688 static int vrf_output6(struct net *net, struct sock *sk, struct sk_buff *skb) in vrf_output6() argument
691 net, sk, skb, NULL, skb_dst(skb)->dev, in vrf_output6()
693 !(IP6CB(skb)->flags & IP6SKB_REROUTED)); in vrf_output6()
701 struct sk_buff *skb) in vrf_ip6_out_redirect() argument
718 vrf_tx_error(vrf_dev, skb); in vrf_ip6_out_redirect()
722 skb_dst_drop(skb); in vrf_ip6_out_redirect()
723 skb_dst_set(skb, dst); in vrf_ip6_out_redirect()
725 return skb; in vrf_ip6_out_redirect()
729 struct sk_buff *skb) in vrf_output6_direct_finish() argument
731 vrf_finish_direct(skb); in vrf_output6_direct_finish()
733 return vrf_ip6_local_out(net, sk, skb); in vrf_output6_direct_finish()
737 struct sk_buff *skb) in vrf_output6_direct() argument
741 skb->protocol = htons(ETH_P_IPV6); in vrf_output6_direct()
743 if (!(IPCB(skb)->flags & IPSKB_REROUTED)) in vrf_output6_direct()
744 err = nf_hook(NFPROTO_IPV6, NF_INET_POST_ROUTING, net, sk, skb, in vrf_output6_direct()
745 NULL, skb->dev, vrf_output6_direct_finish); in vrf_output6_direct()
748 vrf_finish_direct(skb); in vrf_output6_direct()
754 struct sk_buff *skb) in vrf_ip6_out_direct_finish() argument
758 err = vrf_output6_direct(net, sk, skb); in vrf_ip6_out_direct_finish()
760 err = vrf_ip6_local_out(net, sk, skb); in vrf_ip6_out_direct_finish()
767 struct sk_buff *skb) in vrf_ip6_out_direct() argument
772 skb->dev = vrf_dev; in vrf_ip6_out_direct()
775 skb, NULL, vrf_dev, vrf_ip6_out_direct_finish); in vrf_ip6_out_direct()
778 err = vrf_output6_direct(net, sk, skb); in vrf_ip6_out_direct()
781 return skb; in vrf_ip6_out_direct()
788 struct sk_buff *skb) in vrf_ip6_out() argument
791 if (rt6_need_strict(&ipv6_hdr(skb)->daddr)) in vrf_ip6_out()
792 return skb; in vrf_ip6_out()
794 vrf_nf_set_untracked(skb); in vrf_ip6_out()
797 IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) in vrf_ip6_out()
798 return vrf_ip6_out_direct(vrf_dev, sk, skb); in vrf_ip6_out()
800 return vrf_ip6_out_redirect(vrf_dev, skb); in vrf_ip6_out()
857 struct sk_buff *skb) in vrf_ip6_out() argument
859 return skb; in vrf_ip6_out()
873 static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb) in vrf_finish_output() argument
875 struct dst_entry *dst = skb_dst(skb); in vrf_finish_output()
883 vrf_nf_reset_ct(skb); in vrf_finish_output()
886 if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) { in vrf_finish_output()
889 skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev)); in vrf_finish_output()
894 if (skb->sk) in vrf_finish_output()
895 skb_set_owner_w(skb2, skb->sk); in vrf_finish_output()
897 consume_skb(skb); in vrf_finish_output()
898 skb = skb2; in vrf_finish_output()
903 neigh = ip_neigh_for_gw(rt, skb, &is_v6gw); in vrf_finish_output()
905 sock_confirm_neigh(skb, neigh); in vrf_finish_output()
907 ret = neigh_output(neigh, skb, is_v6gw); in vrf_finish_output()
914 vrf_tx_error(skb->dev, skb); in vrf_finish_output()
918 static int vrf_output(struct net *net, struct sock *sk, struct sk_buff *skb) in vrf_output() argument
920 struct net_device *dev = skb_dst(skb)->dev; in vrf_output()
922 IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len); in vrf_output()
924 skb->dev = dev; in vrf_output()
925 skb->protocol = htons(ETH_P_IP); in vrf_output()
928 net, sk, skb, NULL, dev, in vrf_output()
930 !(IPCB(skb)->flags & IPSKB_REROUTED)); in vrf_output()
938 struct sk_buff *skb) in vrf_ip_out_redirect() argument
955 vrf_tx_error(vrf_dev, skb); in vrf_ip_out_redirect()
959 skb_dst_drop(skb); in vrf_ip_out_redirect()
960 skb_dst_set(skb, dst); in vrf_ip_out_redirect()
962 return skb; in vrf_ip_out_redirect()
966 struct sk_buff *skb) in vrf_output_direct_finish() argument
968 vrf_finish_direct(skb); in vrf_output_direct_finish()
970 return vrf_ip_local_out(net, sk, skb); in vrf_output_direct_finish()
974 struct sk_buff *skb) in vrf_output_direct() argument
978 skb->protocol = htons(ETH_P_IP); in vrf_output_direct()
980 if (!(IPCB(skb)->flags & IPSKB_REROUTED)) in vrf_output_direct()
981 err = nf_hook(NFPROTO_IPV4, NF_INET_POST_ROUTING, net, sk, skb, in vrf_output_direct()
982 NULL, skb->dev, vrf_output_direct_finish); in vrf_output_direct()
985 vrf_finish_direct(skb); in vrf_output_direct()
991 struct sk_buff *skb) in vrf_ip_out_direct_finish() argument
995 err = vrf_output_direct(net, sk, skb); in vrf_ip_out_direct_finish()
997 err = vrf_ip_local_out(net, sk, skb); in vrf_ip_out_direct_finish()
1004 struct sk_buff *skb) in vrf_ip_out_direct() argument
1009 skb->dev = vrf_dev; in vrf_ip_out_direct()
1012 skb, NULL, vrf_dev, vrf_ip_out_direct_finish); in vrf_ip_out_direct()
1015 err = vrf_output_direct(net, sk, skb); in vrf_ip_out_direct()
1018 return skb; in vrf_ip_out_direct()
1025 struct sk_buff *skb) in vrf_ip_out() argument
1028 if (ipv4_is_multicast(ip_hdr(skb)->daddr) || in vrf_ip_out()
1029 ipv4_is_lbcast(ip_hdr(skb)->daddr)) in vrf_ip_out()
1030 return skb; in vrf_ip_out()
1032 vrf_nf_set_untracked(skb); in vrf_ip_out()
1035 IPCB(skb)->flags & IPSKB_XFRM_TRANSFORMED) in vrf_ip_out()
1036 return vrf_ip_out_direct(vrf_dev, sk, skb); in vrf_ip_out()
1038 return vrf_ip_out_redirect(vrf_dev, skb); in vrf_ip_out()
1044 struct sk_buff *skb, in vrf_l3_out() argument
1049 return vrf_ip_out(vrf_dev, sk, skb); in vrf_l3_out()
1051 return vrf_ip6_out(vrf_dev, sk, skb); in vrf_l3_out()
1054 return skb; in vrf_l3_out()
1240 static int vrf_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb) in vrf_rcv_finish() argument
1242 kfree_skb(skb); in vrf_rcv_finish()
1247 struct sk_buff *skb, in vrf_rcv_nfhook() argument
1252 if (nf_hook(pf, hook, net, NULL, skb, dev, NULL, vrf_rcv_finish) != 1) in vrf_rcv_nfhook()
1253 skb = NULL; /* kfree_skb(skb) handled by nf code */ in vrf_rcv_nfhook()
1255 return skb; in vrf_rcv_nfhook()
1264 static bool ipv6_ndisc_frame(const struct sk_buff *skb) in ipv6_ndisc_frame() argument
1266 const struct ipv6hdr *iph = ipv6_hdr(skb); in ipv6_ndisc_frame()
1273 icmph = skb_header_pointer(skb, sizeof(*iph), in ipv6_ndisc_frame()
1297 const struct sk_buff *skb, in vrf_ip6_route_lookup() argument
1302 return ip6_pol_route(net, vrf->fib6_table, ifindex, fl6, skb, flags); in vrf_ip6_route_lookup()
1305 static void vrf_ip6_input_dst(struct sk_buff *skb, struct net_device *vrf_dev, in vrf_ip6_input_dst() argument
1308 const struct ipv6hdr *iph = ipv6_hdr(skb); in vrf_ip6_input_dst()
1311 .flowi6_mark = skb->mark, in vrf_ip6_input_dst()
1320 rt6 = vrf_ip6_route_lookup(net, vrf_dev, &fl6, ifindex, skb, in vrf_ip6_input_dst()
1328 skb_dst_set(skb, &rt6->dst); in vrf_ip6_input_dst()
1332 struct sk_buff *skb) in vrf_ip6_rcv() argument
1334 int orig_iif = skb->skb_iif; in vrf_ip6_rcv()
1335 bool need_strict = rt6_need_strict(&ipv6_hdr(skb)->daddr); in vrf_ip6_rcv()
1336 bool is_ndisc = ipv6_ndisc_frame(skb); in vrf_ip6_rcv()
1343 if (skb->pkt_type == PACKET_LOOPBACK || (need_strict && !is_ndisc)) { in vrf_ip6_rcv()
1344 skb->dev = vrf_dev; in vrf_ip6_rcv()
1345 skb->skb_iif = vrf_dev->ifindex; in vrf_ip6_rcv()
1346 IP6CB(skb)->flags |= IP6SKB_L3SLAVE; in vrf_ip6_rcv()
1348 if (skb->pkt_type == PACKET_LOOPBACK) in vrf_ip6_rcv()
1349 skb->pkt_type = PACKET_HOST; in vrf_ip6_rcv()
1350 else if (ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL) in vrf_ip6_rcv()
1351 vrf_ip6_input_dst(skb, vrf_dev, orig_iif); in vrf_ip6_rcv()
1358 vrf_rx_stats(vrf_dev, skb->len); in vrf_ip6_rcv()
1359 skb->dev = vrf_dev; in vrf_ip6_rcv()
1360 skb->skb_iif = vrf_dev->ifindex; in vrf_ip6_rcv()
1363 skb_push(skb, skb->mac_len); in vrf_ip6_rcv()
1364 dev_queue_xmit_nit(skb, vrf_dev); in vrf_ip6_rcv()
1365 skb_pull(skb, skb->mac_len); in vrf_ip6_rcv()
1368 IP6CB(skb)->flags |= IP6SKB_L3SLAVE; in vrf_ip6_rcv()
1372 vrf_ip6_input_dst(skb, vrf_dev, orig_iif); in vrf_ip6_rcv()
1374 skb = vrf_rcv_nfhook(NFPROTO_IPV6, NF_INET_PRE_ROUTING, skb, vrf_dev); in vrf_ip6_rcv()
1376 return skb; in vrf_ip6_rcv()
1381 struct sk_buff *skb) in vrf_ip6_rcv() argument
1383 return skb; in vrf_ip6_rcv()
1388 struct sk_buff *skb) in vrf_ip_rcv() argument
1390 skb->dev = vrf_dev; in vrf_ip_rcv()
1391 skb->skb_iif = vrf_dev->ifindex; in vrf_ip_rcv()
1392 IPCB(skb)->flags |= IPSKB_L3SLAVE; in vrf_ip_rcv()
1394 if (ipv4_is_multicast(ip_hdr(skb)->daddr)) in vrf_ip_rcv()
1400 if (skb->pkt_type == PACKET_LOOPBACK) { in vrf_ip_rcv()
1401 skb->pkt_type = PACKET_HOST; in vrf_ip_rcv()
1405 vrf_rx_stats(vrf_dev, skb->len); in vrf_ip_rcv()
1408 skb_push(skb, skb->mac_len); in vrf_ip_rcv()
1409 dev_queue_xmit_nit(skb, vrf_dev); in vrf_ip_rcv()
1410 skb_pull(skb, skb->mac_len); in vrf_ip_rcv()
1413 skb = vrf_rcv_nfhook(NFPROTO_IPV4, NF_INET_PRE_ROUTING, skb, vrf_dev); in vrf_ip_rcv()
1415 return skb; in vrf_ip_rcv()
1420 struct sk_buff *skb, in vrf_l3_rcv() argument
1425 return vrf_ip_rcv(vrf_dev, skb); in vrf_l3_rcv()
1427 return vrf_ip6_rcv(vrf_dev, skb); in vrf_l3_rcv()
1430 return skb; in vrf_l3_rcv()
1503 struct sk_buff *skb; in vrf_fib_rule() local
1510 skb = nlmsg_new(vrf_fib_rule_nl_size(), GFP_KERNEL); in vrf_fib_rule()
1511 if (!skb) in vrf_fib_rule()
1514 nlh = nlmsg_put(skb, 0, 0, 0, sizeof(*frh), 0); in vrf_fib_rule()
1526 if (nla_put_u8(skb, FRA_PROTOCOL, RTPROT_KERNEL)) in vrf_fib_rule()
1529 if (nla_put_u8(skb, FRA_L3MDEV, 1)) in vrf_fib_rule()
1532 if (nla_put_u32(skb, FRA_PRIORITY, FIB_RULE_PREF)) in vrf_fib_rule()
1535 nlmsg_end(skb, nlh); in vrf_fib_rule()
1538 skb->sk = dev_net(dev)->rtnl; in vrf_fib_rule()
1540 err = fib_nl_newrule(skb, nlh, NULL); in vrf_fib_rule()
1544 err = fib_nl_delrule(skb, nlh, NULL); in vrf_fib_rule()
1548 nlmsg_free(skb); in vrf_fib_rule()
1553 nlmsg_free(skb); in vrf_fib_rule()
1738 static int vrf_fillinfo(struct sk_buff *skb, in vrf_fillinfo() argument
1743 return nla_put_u32(skb, IFLA_VRF_TABLE, vrf->tb_id); in vrf_fillinfo()
1752 static int vrf_fill_slave_info(struct sk_buff *skb, in vrf_fill_slave_info() argument
1758 if (nla_put_u32(skb, IFLA_VRF_PORT_TABLE, vrf->tb_id)) in vrf_fill_slave_info()