19 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25 #include <linux/tcp.h>
26 #include <linux/udp.h>
27 #include <linux/in6.h>
28 #include <linux/if_arp.h>
29 #include <linux/if_vlan.h>
38 const struct nlattr *
attr,
int len,
bool keep_skb);
40 static int make_writable(
struct sk_buff *
skb,
int write_len)
42 if (!skb_cloned(skb) || skb_clone_writable(skb, write_len))
49 static int __pop_vlan_tci(
struct sk_buff *skb,
__be16 *current_tci)
68 vlan_set_encap_proto(skb, vhdr);
70 skb_reset_mac_len(skb);
75 static int pop_vlan(
struct sk_buff *skb)
87 err = __pop_vlan_tci(skb, &tci);
96 err = __pop_vlan_tci(skb, &tci);
100 __vlan_hwaccel_put_tag(skb,
ntohs(tci));
112 if (!__vlan_put_tag(skb, current_tag))
124 static int set_eth_addr(
struct sk_buff *skb,
138 static void set_ip_addr(
struct sk_buff *skb,
struct iphdr *nh,
141 int transport_len = skb->
len - skb_transport_offset(skb);
149 struct udphdr *uh = udp_hdr(skb);
160 csum_replace4(&nh->
check, *addr, new_addr);
165 static void set_ip_ttl(
struct sk_buff *skb,
struct iphdr *nh,
u8 new_ttl)
176 err = make_writable(skb, skb_network_offset(skb) +
177 sizeof(
struct iphdr));
190 ipv4_change_dsfield(nh, 0, ipv4_key->
ipv4_tos);
193 set_ip_ttl(skb, nh, ipv4_key->
ipv4_ttl);
202 inet_proto_csum_replace2(check, skb, *port, new_port, 0);
209 struct udphdr *uh = udp_hdr(skb);
212 set_tp_port(skb, port, new_port, &uh->
check);
227 err = make_writable(skb, skb_transport_offset(skb) +
237 set_udp_port(skb, &uh->
dest, udp_port_key->
udp_dst);
247 err = make_writable(skb, skb_transport_offset(skb) +
269 vport = ovs_vport_rcu(dp, out_port);
287 upcall.key = &
OVS_CB(skb)->flow->key;
288 upcall.userdata =
NULL;
291 for (a = nla_data(attr), rem =
nla_len(attr); rem > 0;
292 a = nla_next(a, &rem)) {
299 upcall.portid = nla_get_u32(a);
308 const struct nlattr *attr)
314 for (a = nla_data(attr), rem =
nla_len(attr); rem > 0;
315 a = nla_next(a, &rem)) {
328 return do_execute_actions(dp, skb, nla_data(acts_list),
332 static int execute_set_action(
struct sk_buff *skb,
333 const struct nlattr *nested_attr)
339 skb->
priority = nla_get_u32(nested_attr);
343 err = set_eth_addr(skb, nla_data(nested_attr));
347 err = set_ipv4(skb, nla_data(nested_attr));
351 err = set_tcp(skb, nla_data(nested_attr));
355 err = set_udp(skb, nla_data(nested_attr));
363 static int do_execute_actions(
struct datapath *dp,
struct sk_buff *skb,
364 const struct nlattr *attr,
int len,
bool keep_skb)
374 for (a = attr, rem = len; rem > 0;
375 a = nla_next(a, &rem)) {
378 if (prev_port != -1) {
385 prev_port = nla_get_u32(a);
389 output_userspace(dp, skb, a);
393 err = push_vlan(skb, nla_data(a));
403 err = execute_set_action(skb, nla_data(a));
417 if (prev_port != -1) {
421 do_output(dp, skb, prev_port);
422 }
else if (!keep_skb)
433 return do_execute_actions(dp, skb, acts->
actions,