Lines Matching refs:skb
49 struct sk_buff *skb; member
136 static struct deferred_action *add_deferred_actions(struct sk_buff *skb, in add_deferred_actions() argument
147 da->skb = skb; in add_deferred_actions()
166 static int clone_execute(struct datapath *dp, struct sk_buff *skb,
172 static void update_ethertype(struct sk_buff *skb, struct ethhdr *hdr, in update_ethertype() argument
175 if (skb->ip_summed == CHECKSUM_COMPLETE) { in update_ethertype()
178 skb->csum = ~csum_partial((char *)diff, sizeof(diff), in update_ethertype()
179 ~skb->csum); in update_ethertype()
185 static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key, in push_mpls() argument
191 if (skb->encapsulation) in push_mpls()
194 if (skb_cow_head(skb, MPLS_HLEN) < 0) in push_mpls()
197 if (!skb->inner_protocol) { in push_mpls()
198 skb_set_inner_network_header(skb, skb->mac_len); in push_mpls()
199 skb_set_inner_protocol(skb, skb->protocol); in push_mpls()
202 skb_push(skb, MPLS_HLEN); in push_mpls()
203 memmove(skb_mac_header(skb) - MPLS_HLEN, skb_mac_header(skb), in push_mpls()
204 skb->mac_len); in push_mpls()
205 skb_reset_mac_header(skb); in push_mpls()
206 skb_set_network_header(skb, skb->mac_len); in push_mpls()
208 new_mpls_lse = mpls_hdr(skb); in push_mpls()
211 skb_postpush_rcsum(skb, new_mpls_lse, MPLS_HLEN); in push_mpls()
214 update_ethertype(skb, eth_hdr(skb), mpls->mpls_ethertype); in push_mpls()
215 skb->protocol = mpls->mpls_ethertype; in push_mpls()
221 static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, in pop_mpls() argument
226 err = skb_ensure_writable(skb, skb->mac_len + MPLS_HLEN); in pop_mpls()
230 skb_postpull_rcsum(skb, mpls_hdr(skb), MPLS_HLEN); in pop_mpls()
232 memmove(skb_mac_header(skb) + MPLS_HLEN, skb_mac_header(skb), in pop_mpls()
233 skb->mac_len); in pop_mpls()
235 __skb_pull(skb, MPLS_HLEN); in pop_mpls()
236 skb_reset_mac_header(skb); in pop_mpls()
237 skb_set_network_header(skb, skb->mac_len); in pop_mpls()
245 hdr = (struct ethhdr *)((void *)mpls_hdr(skb) - ETH_HLEN); in pop_mpls()
246 update_ethertype(skb, hdr, ethertype); in pop_mpls()
248 if (eth_p_mpls(skb->protocol)) in pop_mpls()
249 skb->protocol = ethertype; in pop_mpls()
255 static int set_mpls(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_mpls() argument
262 err = skb_ensure_writable(skb, skb->mac_len + MPLS_HLEN); in set_mpls()
266 stack = mpls_hdr(skb); in set_mpls()
268 if (skb->ip_summed == CHECKSUM_COMPLETE) { in set_mpls()
271 skb->csum = ~csum_partial((char *)diff, sizeof(diff), in set_mpls()
272 ~skb->csum); in set_mpls()
280 static int pop_vlan(struct sk_buff *skb, struct sw_flow_key *key) in pop_vlan() argument
284 err = skb_vlan_pop(skb); in pop_vlan()
285 if (skb_vlan_tag_present(skb)) { in pop_vlan()
294 static int push_vlan(struct sk_buff *skb, struct sw_flow_key *key, in push_vlan() argument
297 if (skb_vlan_tag_present(skb)) { in push_vlan()
303 return skb_vlan_push(skb, vlan->vlan_tpid, in push_vlan()
319 static int set_eth_addr(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_eth_addr() argument
325 err = skb_ensure_writable(skb, ETH_HLEN); in set_eth_addr()
329 skb_postpull_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2); in set_eth_addr()
331 ether_addr_copy_masked(eth_hdr(skb)->h_source, key->eth_src, in set_eth_addr()
333 ether_addr_copy_masked(eth_hdr(skb)->h_dest, key->eth_dst, in set_eth_addr()
336 skb_postpush_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2); in set_eth_addr()
338 ether_addr_copy(flow_key->eth.src, eth_hdr(skb)->h_source); in set_eth_addr()
339 ether_addr_copy(flow_key->eth.dst, eth_hdr(skb)->h_dest); in set_eth_addr()
346 static int pop_eth(struct sk_buff *skb, struct sw_flow_key *key) in pop_eth() argument
348 skb_pull_rcsum(skb, ETH_HLEN); in pop_eth()
349 skb_reset_mac_header(skb); in pop_eth()
350 skb_reset_mac_len(skb); in pop_eth()
358 static int push_eth(struct sk_buff *skb, struct sw_flow_key *key, in push_eth() argument
364 if (skb_cow_head(skb, ETH_HLEN) < 0) in push_eth()
367 skb_push(skb, ETH_HLEN); in push_eth()
368 skb_reset_mac_header(skb); in push_eth()
369 skb_reset_mac_len(skb); in push_eth()
371 hdr = eth_hdr(skb); in push_eth()
374 hdr->h_proto = skb->protocol; in push_eth()
376 skb_postpush_rcsum(skb, hdr, ETH_HLEN); in push_eth()
384 static int push_nsh(struct sk_buff *skb, struct sw_flow_key *key, in push_nsh() argument
389 err = nsh_push(skb, nh); in push_nsh()
399 static int pop_nsh(struct sk_buff *skb, struct sw_flow_key *key) in pop_nsh() argument
403 err = nsh_pop(skb); in pop_nsh()
408 if (skb->protocol == htons(ETH_P_TEB)) in pop_nsh()
416 static void update_ip_l4_checksum(struct sk_buff *skb, struct iphdr *nh, in update_ip_l4_checksum() argument
419 int transport_len = skb->len - skb_transport_offset(skb); in update_ip_l4_checksum()
426 inet_proto_csum_replace4(&tcp_hdr(skb)->check, skb, in update_ip_l4_checksum()
430 struct udphdr *uh = udp_hdr(skb); in update_ip_l4_checksum()
432 if (uh->check || skb->ip_summed == CHECKSUM_PARTIAL) { in update_ip_l4_checksum()
433 inet_proto_csum_replace4(&uh->check, skb, in update_ip_l4_checksum()
442 static void set_ip_addr(struct sk_buff *skb, struct iphdr *nh, in set_ip_addr() argument
445 update_ip_l4_checksum(skb, nh, *addr, new_addr); in set_ip_addr()
447 skb_clear_hash(skb); in set_ip_addr()
451 static void update_ipv6_checksum(struct sk_buff *skb, u8 l4_proto, in update_ipv6_checksum() argument
454 int transport_len = skb->len - skb_transport_offset(skb); in update_ipv6_checksum()
458 inet_proto_csum_replace16(&tcp_hdr(skb)->check, skb, in update_ipv6_checksum()
462 struct udphdr *uh = udp_hdr(skb); in update_ipv6_checksum()
464 if (uh->check || skb->ip_summed == CHECKSUM_PARTIAL) { in update_ipv6_checksum()
465 inet_proto_csum_replace16(&uh->check, skb, in update_ipv6_checksum()
473 inet_proto_csum_replace16(&icmp6_hdr(skb)->icmp6_cksum, in update_ipv6_checksum()
474 skb, addr, new_addr, true); in update_ipv6_checksum()
487 static void set_ipv6_addr(struct sk_buff *skb, u8 l4_proto, in set_ipv6_addr() argument
492 update_ipv6_checksum(skb, l4_proto, addr, new_addr); in set_ipv6_addr()
494 skb_clear_hash(skb); in set_ipv6_addr()
506 static void set_ip_ttl(struct sk_buff *skb, struct iphdr *nh, u8 new_ttl, in set_ip_ttl() argument
515 static int set_ipv4(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_ipv4() argument
523 err = skb_ensure_writable(skb, skb_network_offset(skb) + in set_ipv4()
528 nh = ip_hdr(skb); in set_ipv4()
538 set_ip_addr(skb, nh, &nh->saddr, new_addr); in set_ipv4()
546 set_ip_addr(skb, nh, &nh->daddr, new_addr); in set_ipv4()
555 set_ip_ttl(skb, nh, key->ipv4_ttl, mask->ipv4_ttl); in set_ipv4()
567 static int set_ipv6(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_ipv6() argument
574 err = skb_ensure_writable(skb, skb_network_offset(skb) + in set_ipv6()
579 nh = ipv6_hdr(skb); in set_ipv6()
592 set_ipv6_addr(skb, flow_key->ip.proto, saddr, masked, in set_ipv6()
609 recalc_csum = (ipv6_find_hdr(skb, &offset, in set_ipv6()
614 set_ipv6_addr(skb, flow_key->ip.proto, daddr, masked, in set_ipv6()
638 static int set_nsh(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_nsh() argument
656 if (!pskb_may_pull(skb, skb_network_offset(skb) + NSH_BASE_HDR_LEN)) in set_nsh()
659 nh = nsh_hdr(skb); in set_nsh()
663 err = skb_ensure_writable(skb, skb_network_offset(skb) + in set_nsh()
668 nh = nsh_hdr(skb); in set_nsh()
669 skb_postpull_rcsum(skb, nh, length); in set_nsh()
697 skb_postpush_rcsum(skb, nh, length); in set_nsh()
702 static void set_tp_port(struct sk_buff *skb, __be16 *port, in set_tp_port() argument
705 inet_proto_csum_replace2(check, skb, *port, new_port, false); in set_tp_port()
709 static int set_udp(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_udp() argument
717 err = skb_ensure_writable(skb, skb_transport_offset(skb) + in set_udp()
722 uh = udp_hdr(skb); in set_udp()
727 if (uh->check && skb->ip_summed != CHECKSUM_PARTIAL) { in set_udp()
729 set_tp_port(skb, &uh->source, src, &uh->check); in set_udp()
733 set_tp_port(skb, &uh->dest, dst, &uh->check); in set_udp()
746 skb_clear_hash(skb); in set_udp()
751 static int set_tcp(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_tcp() argument
759 err = skb_ensure_writable(skb, skb_transport_offset(skb) + in set_tcp()
764 th = tcp_hdr(skb); in set_tcp()
767 set_tp_port(skb, &th->source, src, &th->check); in set_tcp()
772 set_tp_port(skb, &th->dest, dst, &th->check); in set_tcp()
775 skb_clear_hash(skb); in set_tcp()
780 static int set_sctp(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_sctp() argument
784 unsigned int sctphoff = skb_transport_offset(skb); in set_sctp()
789 err = skb_ensure_writable(skb, sctphoff + sizeof(struct sctphdr)); in set_sctp()
793 sh = sctp_hdr(skb); in set_sctp()
795 old_correct_csum = sctp_compute_cksum(skb, sctphoff); in set_sctp()
800 new_csum = sctp_compute_cksum(skb, sctphoff); in set_sctp()
805 skb_clear_hash(skb); in set_sctp()
812 static int ovs_vport_output(struct net *net, struct sock *sk, struct sk_buff *skb) in ovs_vport_output() argument
817 if (skb_cow_head(skb, data->l2_len) < 0) { in ovs_vport_output()
818 kfree_skb(skb); in ovs_vport_output()
822 __skb_dst_copy(skb, data->dst); in ovs_vport_output()
823 *OVS_CB(skb) = data->cb; in ovs_vport_output()
824 skb->inner_protocol = data->inner_protocol; in ovs_vport_output()
825 skb->vlan_tci = data->vlan_tci; in ovs_vport_output()
826 skb->vlan_proto = data->vlan_proto; in ovs_vport_output()
829 skb_push(skb, data->l2_len); in ovs_vport_output()
830 memcpy(skb->data, &data->l2_data, data->l2_len); in ovs_vport_output()
831 skb_postpush_rcsum(skb, skb->data, data->l2_len); in ovs_vport_output()
832 skb_reset_mac_header(skb); in ovs_vport_output()
834 if (eth_p_mpls(skb->protocol)) { in ovs_vport_output()
835 skb->inner_network_header = skb->network_header; in ovs_vport_output()
836 skb_set_network_header(skb, data->network_offset); in ovs_vport_output()
837 skb_reset_mac_len(skb); in ovs_vport_output()
840 ovs_vport_send(vport, skb, data->mac_proto); in ovs_vport_output()
858 static void prepare_frag(struct vport *vport, struct sk_buff *skb, in prepare_frag() argument
861 unsigned int hlen = skb_network_offset(skb); in prepare_frag()
865 data->dst = skb->_skb_refdst; in prepare_frag()
867 data->cb = *OVS_CB(skb); in prepare_frag()
868 data->inner_protocol = skb->inner_protocol; in prepare_frag()
870 data->vlan_tci = skb->vlan_tci; in prepare_frag()
871 data->vlan_proto = skb->vlan_proto; in prepare_frag()
874 memcpy(&data->l2_data, skb->data, hlen); in prepare_frag()
876 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); in prepare_frag()
877 skb_pull(skb, hlen); in prepare_frag()
881 struct sk_buff *skb, u16 mru, in ovs_fragment() argument
886 if (eth_p_mpls(skb->protocol)) { in ovs_fragment()
887 orig_network_offset = skb_network_offset(skb); in ovs_fragment()
888 skb->network_header = skb->inner_network_header; in ovs_fragment()
891 if (skb_network_offset(skb) > MAX_L2_LEN) { in ovs_fragment()
900 prepare_frag(vport, skb, orig_network_offset, in ovs_fragment()
906 orig_dst = skb->_skb_refdst; in ovs_fragment()
907 skb_dst_set_noref(skb, &ovs_dst); in ovs_fragment()
908 IPCB(skb)->frag_max_size = mru; in ovs_fragment()
910 ip_do_fragment(net, skb->sk, skb, ovs_vport_output); in ovs_fragment()
920 prepare_frag(vport, skb, orig_network_offset, in ovs_fragment()
927 orig_dst = skb->_skb_refdst; in ovs_fragment()
928 skb_dst_set_noref(skb, &ovs_rt.dst); in ovs_fragment()
929 IP6CB(skb)->frag_max_size = mru; in ovs_fragment()
931 v6ops->fragment(net, skb->sk, skb, ovs_vport_output); in ovs_fragment()
942 kfree_skb(skb); in ovs_fragment()
945 static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port, in do_output() argument
951 u16 mru = OVS_CB(skb)->mru; in do_output()
952 u32 cutlen = OVS_CB(skb)->cutlen; in do_output()
955 if (skb->len - cutlen > ovs_mac_header_len(key)) in do_output()
956 pskb_trim(skb, skb->len - cutlen); in do_output()
958 pskb_trim(skb, ovs_mac_header_len(key)); in do_output()
962 (skb->len <= mru + vport->dev->hard_header_len))) { in do_output()
963 ovs_vport_send(vport, skb, ovs_key_mac_proto(key)); in do_output()
967 ovs_fragment(net, vport, skb, mru, key); in do_output()
969 kfree_skb(skb); in do_output()
972 kfree_skb(skb); in do_output()
976 static int output_userspace(struct datapath *dp, struct sk_buff *skb, in output_userspace() argument
987 upcall.mru = OVS_CB(skb)->mru; in output_userspace()
1008 err = dev_fill_metadata_dst(vport->dev, skb); in output_userspace()
1010 upcall.egress_tun_info = skb_tunnel_info(skb); in output_userspace()
1026 return ovs_dp_upcall(dp, skb, key, &upcall, cutlen); in output_userspace()
1033 static int sample(struct datapath *dp, struct sk_buff *skb, in sample() argument
1051 consume_skb(skb); in sample()
1056 return clone_execute(dp, skb, key, 0, actions, rem, last, in sample()
1064 static int clone(struct datapath *dp, struct sk_buff *skb, in clone() argument
1078 return clone_execute(dp, skb, key, 0, actions, rem, last, in clone()
1082 static void execute_hash(struct sk_buff *skb, struct sw_flow_key *key, in execute_hash() argument
1089 hash = skb_get_hash(skb); in execute_hash()
1097 static int execute_set_action(struct sk_buff *skb, in execute_set_action() argument
1105 skb_dst_drop(skb); in execute_set_action()
1107 skb_dst_set(skb, (struct dst_entry *)tun->tun_dst); in execute_set_action()
1117 static int execute_masked_set_action(struct sk_buff *skb, in execute_masked_set_action() argument
1125 OVS_SET_MASKED(skb->priority, nla_get_u32(a), in execute_masked_set_action()
1127 flow_key->phy.priority = skb->priority; in execute_masked_set_action()
1131 OVS_SET_MASKED(skb->mark, nla_get_u32(a), *get_mask(a, u32 *)); in execute_masked_set_action()
1132 flow_key->phy.skb_mark = skb->mark; in execute_masked_set_action()
1141 err = set_eth_addr(skb, flow_key, nla_data(a), in execute_masked_set_action()
1146 err = set_nsh(skb, flow_key, a); in execute_masked_set_action()
1150 err = set_ipv4(skb, flow_key, nla_data(a), in execute_masked_set_action()
1155 err = set_ipv6(skb, flow_key, nla_data(a), in execute_masked_set_action()
1160 err = set_tcp(skb, flow_key, nla_data(a), in execute_masked_set_action()
1165 err = set_udp(skb, flow_key, nla_data(a), in execute_masked_set_action()
1170 err = set_sctp(skb, flow_key, nla_data(a), in execute_masked_set_action()
1175 err = set_mpls(skb, flow_key, nla_data(a), get_mask(a, in execute_masked_set_action()
1192 static int execute_recirc(struct datapath *dp, struct sk_buff *skb, in execute_recirc() argument
1201 err = ovs_flow_key_update(skb, key); in execute_recirc()
1208 return clone_execute(dp, skb, key, recirc_id, NULL, 0, last, true); in execute_recirc()
1212 static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, in do_execute_actions() argument
1233 do_output(dp, skb, port, key); in do_execute_actions()
1239 clone = skb_clone(skb, GFP_ATOMIC); in do_execute_actions()
1242 OVS_CB(skb)->cutlen = 0; in do_execute_actions()
1249 if (skb->len > trunc->max_len) in do_execute_actions()
1250 OVS_CB(skb)->cutlen = skb->len - trunc->max_len; in do_execute_actions()
1255 output_userspace(dp, skb, key, a, attr, in do_execute_actions()
1256 len, OVS_CB(skb)->cutlen); in do_execute_actions()
1257 OVS_CB(skb)->cutlen = 0; in do_execute_actions()
1261 execute_hash(skb, key, a); in do_execute_actions()
1265 err = push_mpls(skb, key, nla_data(a)); in do_execute_actions()
1269 err = pop_mpls(skb, key, nla_get_be16(a)); in do_execute_actions()
1273 err = push_vlan(skb, key, nla_data(a)); in do_execute_actions()
1277 err = pop_vlan(skb, key); in do_execute_actions()
1283 err = execute_recirc(dp, skb, key, a, last); in do_execute_actions()
1295 err = execute_set_action(skb, key, nla_data(a)); in do_execute_actions()
1300 err = execute_masked_set_action(skb, key, nla_data(a)); in do_execute_actions()
1306 err = sample(dp, skb, key, a, last); in do_execute_actions()
1315 err = ovs_flow_key_update(skb, key); in do_execute_actions()
1320 err = ovs_ct_execute(ovs_dp_get_net(dp), skb, key, in do_execute_actions()
1329 err = ovs_ct_clear(skb, key); in do_execute_actions()
1333 err = push_eth(skb, key, nla_data(a)); in do_execute_actions()
1337 err = pop_eth(skb, key); in do_execute_actions()
1348 err = push_nsh(skb, key, nh); in do_execute_actions()
1353 err = pop_nsh(skb, key); in do_execute_actions()
1357 if (ovs_meter_execute(dp, skb, key, nla_get_u32(a))) { in do_execute_actions()
1358 consume_skb(skb); in do_execute_actions()
1366 err = clone(dp, skb, key, a, last); in do_execute_actions()
1375 kfree_skb(skb); in do_execute_actions()
1380 consume_skb(skb); in do_execute_actions()
1390 static int clone_execute(struct datapath *dp, struct sk_buff *skb, in clone_execute() argument
1398 skb = last ? skb : skb_clone(skb, GFP_ATOMIC); in clone_execute()
1399 if (!skb) { in clone_execute()
1419 err = do_execute_actions(dp, skb, clone, in clone_execute()
1426 ovs_dp_process_packet(skb, clone); in clone_execute()
1432 da = add_deferred_actions(skb, key, actions, len); in clone_execute()
1442 kfree_skb(skb); in clone_execute()
1468 struct sk_buff *skb = da->skb; in process_deferred_actions() local
1474 do_execute_actions(dp, skb, key, actions, actions_len); in process_deferred_actions()
1476 ovs_dp_process_packet(skb, key); in process_deferred_actions()
1484 int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb, in ovs_execute_actions() argument
1494 kfree_skb(skb); in ovs_execute_actions()
1499 OVS_CB(skb)->acts_origlen = acts->orig_len; in ovs_execute_actions()
1500 err = do_execute_actions(dp, skb, key, in ovs_execute_actions()