Lines Matching refs:skb
43 static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
48 struct sk_buff *skb; member
94 static struct deferred_action *add_deferred_actions(struct sk_buff *skb, in add_deferred_actions() argument
104 da->skb = skb; in add_deferred_actions()
122 static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key, in push_mpls() argument
129 if (skb->encapsulation) in push_mpls()
132 if (skb_cow_head(skb, MPLS_HLEN) < 0) in push_mpls()
135 skb_push(skb, MPLS_HLEN); in push_mpls()
136 memmove(skb_mac_header(skb) - MPLS_HLEN, skb_mac_header(skb), in push_mpls()
137 skb->mac_len); in push_mpls()
138 skb_reset_mac_header(skb); in push_mpls()
140 new_mpls_lse = (__be32 *)skb_mpls_header(skb); in push_mpls()
143 if (skb->ip_summed == CHECKSUM_COMPLETE) in push_mpls()
144 skb->csum = csum_add(skb->csum, csum_partial(new_mpls_lse, in push_mpls()
147 hdr = eth_hdr(skb); in push_mpls()
150 if (!skb->inner_protocol) in push_mpls()
151 skb_set_inner_protocol(skb, skb->protocol); in push_mpls()
152 skb->protocol = mpls->mpls_ethertype; in push_mpls()
158 static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key, in pop_mpls() argument
164 err = skb_ensure_writable(skb, skb->mac_len + MPLS_HLEN); in pop_mpls()
168 skb_postpull_rcsum(skb, skb_mpls_header(skb), MPLS_HLEN); in pop_mpls()
170 memmove(skb_mac_header(skb) + MPLS_HLEN, skb_mac_header(skb), in pop_mpls()
171 skb->mac_len); in pop_mpls()
173 __skb_pull(skb, MPLS_HLEN); in pop_mpls()
174 skb_reset_mac_header(skb); in pop_mpls()
179 hdr = (struct ethhdr *)(skb_mpls_header(skb) - ETH_HLEN); in pop_mpls()
181 if (eth_p_mpls(skb->protocol)) in pop_mpls()
182 skb->protocol = ethertype; in pop_mpls()
192 static int set_mpls(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_mpls() argument
199 err = skb_ensure_writable(skb, skb->mac_len + MPLS_HLEN); in set_mpls()
203 stack = (__be32 *)skb_mpls_header(skb); in set_mpls()
205 if (skb->ip_summed == CHECKSUM_COMPLETE) { in set_mpls()
208 skb->csum = ~csum_partial((char *)diff, sizeof(diff), in set_mpls()
209 ~skb->csum); in set_mpls()
217 static int pop_vlan(struct sk_buff *skb, struct sw_flow_key *key) in pop_vlan() argument
221 err = skb_vlan_pop(skb); in pop_vlan()
222 if (skb_vlan_tag_present(skb)) in pop_vlan()
229 static int push_vlan(struct sk_buff *skb, struct sw_flow_key *key, in push_vlan() argument
232 if (skb_vlan_tag_present(skb)) in push_vlan()
236 return skb_vlan_push(skb, vlan->vlan_tpid, in push_vlan()
252 static int set_eth_addr(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_eth_addr() argument
258 err = skb_ensure_writable(skb, ETH_HLEN); in set_eth_addr()
262 skb_postpull_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2); in set_eth_addr()
264 ether_addr_copy_masked(eth_hdr(skb)->h_source, key->eth_src, in set_eth_addr()
266 ether_addr_copy_masked(eth_hdr(skb)->h_dest, key->eth_dst, in set_eth_addr()
269 ovs_skb_postpush_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2); in set_eth_addr()
271 ether_addr_copy(flow_key->eth.src, eth_hdr(skb)->h_source); in set_eth_addr()
272 ether_addr_copy(flow_key->eth.dst, eth_hdr(skb)->h_dest); in set_eth_addr()
276 static void set_ip_addr(struct sk_buff *skb, struct iphdr *nh, in set_ip_addr() argument
279 int transport_len = skb->len - skb_transport_offset(skb); in set_ip_addr()
283 inet_proto_csum_replace4(&tcp_hdr(skb)->check, skb, in set_ip_addr()
287 struct udphdr *uh = udp_hdr(skb); in set_ip_addr()
289 if (uh->check || skb->ip_summed == CHECKSUM_PARTIAL) { in set_ip_addr()
290 inet_proto_csum_replace4(&uh->check, skb, in set_ip_addr()
299 skb_clear_hash(skb); in set_ip_addr()
303 static void update_ipv6_checksum(struct sk_buff *skb, u8 l4_proto, in update_ipv6_checksum() argument
306 int transport_len = skb->len - skb_transport_offset(skb); in update_ipv6_checksum()
310 inet_proto_csum_replace16(&tcp_hdr(skb)->check, skb, in update_ipv6_checksum()
314 struct udphdr *uh = udp_hdr(skb); in update_ipv6_checksum()
316 if (uh->check || skb->ip_summed == CHECKSUM_PARTIAL) { in update_ipv6_checksum()
317 inet_proto_csum_replace16(&uh->check, skb, in update_ipv6_checksum()
325 inet_proto_csum_replace16(&icmp6_hdr(skb)->icmp6_cksum, in update_ipv6_checksum()
326 skb, addr, new_addr, 1); in update_ipv6_checksum()
339 static void set_ipv6_addr(struct sk_buff *skb, u8 l4_proto, in set_ipv6_addr() argument
344 update_ipv6_checksum(skb, l4_proto, addr, new_addr); in set_ipv6_addr()
346 skb_clear_hash(skb); in set_ipv6_addr()
358 static void set_ip_ttl(struct sk_buff *skb, struct iphdr *nh, u8 new_ttl, in set_ip_ttl() argument
367 static int set_ipv4(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_ipv4() argument
375 err = skb_ensure_writable(skb, skb_network_offset(skb) + in set_ipv4()
380 nh = ip_hdr(skb); in set_ipv4()
390 set_ip_addr(skb, nh, &nh->saddr, new_addr); in set_ipv4()
398 set_ip_addr(skb, nh, &nh->daddr, new_addr); in set_ipv4()
407 set_ip_ttl(skb, nh, key->ipv4_ttl, mask->ipv4_ttl); in set_ipv4()
419 static int set_ipv6(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_ipv6() argument
426 err = skb_ensure_writable(skb, skb_network_offset(skb) + in set_ipv6()
431 nh = ipv6_hdr(skb); in set_ipv6()
444 set_ipv6_addr(skb, key->ipv6_proto, saddr, masked, in set_ipv6()
461 recalc_csum = (ipv6_find_hdr(skb, &offset, in set_ipv6()
466 set_ipv6_addr(skb, key->ipv6_proto, daddr, masked, in set_ipv6()
490 static void set_tp_port(struct sk_buff *skb, __be16 *port, in set_tp_port() argument
493 inet_proto_csum_replace2(check, skb, *port, new_port, 0); in set_tp_port()
497 static int set_udp(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_udp() argument
505 err = skb_ensure_writable(skb, skb_transport_offset(skb) + in set_udp()
510 uh = udp_hdr(skb); in set_udp()
515 if (uh->check && skb->ip_summed != CHECKSUM_PARTIAL) { in set_udp()
517 set_tp_port(skb, &uh->source, src, &uh->check); in set_udp()
521 set_tp_port(skb, &uh->dest, dst, &uh->check); in set_udp()
534 skb_clear_hash(skb); in set_udp()
539 static int set_tcp(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_tcp() argument
547 err = skb_ensure_writable(skb, skb_transport_offset(skb) + in set_tcp()
552 th = tcp_hdr(skb); in set_tcp()
555 set_tp_port(skb, &th->source, src, &th->check); in set_tcp()
560 set_tp_port(skb, &th->dest, dst, &th->check); in set_tcp()
563 skb_clear_hash(skb); in set_tcp()
568 static int set_sctp(struct sk_buff *skb, struct sw_flow_key *flow_key, in set_sctp() argument
572 unsigned int sctphoff = skb_transport_offset(skb); in set_sctp()
577 err = skb_ensure_writable(skb, sctphoff + sizeof(struct sctphdr)); in set_sctp()
581 sh = sctp_hdr(skb); in set_sctp()
583 old_correct_csum = sctp_compute_cksum(skb, sctphoff); in set_sctp()
588 new_csum = sctp_compute_cksum(skb, sctphoff); in set_sctp()
593 skb_clear_hash(skb); in set_sctp()
600 static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port) in do_output() argument
605 ovs_vport_send(vport, skb); in do_output()
607 kfree_skb(skb); in do_output()
610 static int output_userspace(struct datapath *dp, struct sk_buff *skb, in output_userspace() argument
642 err = ovs_vport_get_egress_tun_info(vport, skb, in output_userspace()
653 return ovs_dp_upcall(dp, skb, key, &upcall); in output_userspace()
656 static int sample(struct datapath *dp, struct sk_buff *skb, in sample() argument
691 return output_userspace(dp, skb, key, a); in sample()
693 skb = skb_clone(skb, GFP_ATOMIC); in sample()
694 if (!skb) in sample()
698 if (!add_deferred_actions(skb, key, a)) { in sample()
703 kfree_skb(skb); in sample()
708 static void execute_hash(struct sk_buff *skb, struct sw_flow_key *key, in execute_hash() argument
715 hash = skb_get_hash(skb); in execute_hash()
723 static int execute_set_action(struct sk_buff *skb, in execute_set_action() argument
729 OVS_CB(skb)->egress_tun_info = nla_data(a); in execute_set_action()
739 static int execute_masked_set_action(struct sk_buff *skb, in execute_masked_set_action() argument
747 SET_MASKED(skb->priority, nla_get_u32(a), *get_mask(a, u32 *)); in execute_masked_set_action()
748 flow_key->phy.priority = skb->priority; in execute_masked_set_action()
752 SET_MASKED(skb->mark, nla_get_u32(a), *get_mask(a, u32 *)); in execute_masked_set_action()
753 flow_key->phy.skb_mark = skb->mark; in execute_masked_set_action()
762 err = set_eth_addr(skb, flow_key, nla_data(a), in execute_masked_set_action()
767 err = set_ipv4(skb, flow_key, nla_data(a), in execute_masked_set_action()
772 err = set_ipv6(skb, flow_key, nla_data(a), in execute_masked_set_action()
777 err = set_tcp(skb, flow_key, nla_data(a), in execute_masked_set_action()
782 err = set_udp(skb, flow_key, nla_data(a), in execute_masked_set_action()
787 err = set_sctp(skb, flow_key, nla_data(a), in execute_masked_set_action()
792 err = set_mpls(skb, flow_key, nla_data(a), get_mask(a, in execute_masked_set_action()
800 static int execute_recirc(struct datapath *dp, struct sk_buff *skb, in execute_recirc() argument
809 err = ovs_flow_key_update(skb, key); in execute_recirc()
819 skb = skb_clone(skb, GFP_ATOMIC); in execute_recirc()
824 if (!skb) in execute_recirc()
828 da = add_deferred_actions(skb, key, NULL); in execute_recirc()
832 kfree_skb(skb); in execute_recirc()
843 static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, in do_execute_actions() argument
861 struct sk_buff *out_skb = skb_clone(skb, GFP_ATOMIC); in do_execute_actions()
875 output_userspace(dp, skb, key, a); in do_execute_actions()
879 execute_hash(skb, key, a); in do_execute_actions()
883 err = push_mpls(skb, key, nla_data(a)); in do_execute_actions()
887 err = pop_mpls(skb, key, nla_get_be16(a)); in do_execute_actions()
891 err = push_vlan(skb, key, nla_data(a)); in do_execute_actions()
895 err = pop_vlan(skb, key); in do_execute_actions()
899 err = execute_recirc(dp, skb, key, a, rem); in do_execute_actions()
910 err = execute_set_action(skb, key, nla_data(a)); in do_execute_actions()
915 err = execute_masked_set_action(skb, key, nla_data(a)); in do_execute_actions()
919 err = sample(dp, skb, key, a); in do_execute_actions()
924 kfree_skb(skb); in do_execute_actions()
930 do_output(dp, skb, prev_port); in do_execute_actions()
932 consume_skb(skb); in do_execute_actions()
948 struct sk_buff *skb = da->skb; in process_deferred_actions() local
953 do_execute_actions(dp, skb, key, actions, in process_deferred_actions()
956 ovs_dp_process_packet(skb, key); in process_deferred_actions()
964 int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb, in ovs_execute_actions() argument
972 OVS_CB(skb)->egress_tun_info = NULL; in ovs_execute_actions()
973 err = do_execute_actions(dp, skb, key, in ovs_execute_actions()