#include <net/ipv6.h>
#include <net/checksum.h>
#include <net/dsfield.h>
+#include <net/mpls.h>
#include <net/sctp/checksum.h>
#include "datapath.h"
#include "gso.h"
-#include "mpls.h"
#include "vlan.h"
#include "vport.h"
return pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
}
-/* The end of the mac header.
- *
- * For non-MPLS skbs this will correspond to the network header.
- * For MPLS skbs it will be before the network_header as the MPLS
- * label stack lies between the end of the mac header and the network
- * header. That is, for MPLS skbs the end of the mac header
- * is the top of the MPLS label stack.
- */
-static unsigned char *mac_header_end(const struct sk_buff *skb)
-{
- return skb_mac_header(skb) + skb->mac_len;
-}
-
static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key,
const struct ovs_action_push_mpls *mpls)
{
__be32 *new_mpls_lse;
struct ethhdr *hdr;
+ /* Networking stack do not allow simultaneous Tunnel and MPLS GSO. */
+ if (skb_encapsulation(skb))
+ return -ENOTSUPP;
+
if (skb_cow_head(skb, MPLS_HLEN) < 0)
return -ENOMEM;
skb->mac_len);
skb_reset_mac_header(skb);
- new_mpls_lse = (__be32 *)mac_header_end(skb);
+ new_mpls_lse = (__be32 *)skb_mpls_header(skb);
*new_mpls_lse = mpls->mpls_lse;
if (skb->ip_summed == CHECKSUM_COMPLETE)
if (!ovs_skb_get_inner_protocol(skb))
ovs_skb_set_inner_protocol(skb, skb->protocol);
skb->protocol = mpls->mpls_ethertype;
+
invalidate_flow_key(key);
return 0;
}
if (skb->ip_summed == CHECKSUM_COMPLETE)
skb->csum = csum_sub(skb->csum,
- csum_partial(mac_header_end(skb),
+ csum_partial(skb_mpls_header(skb),
MPLS_HLEN, 0));
memmove(skb_mac_header(skb) + MPLS_HLEN, skb_mac_header(skb),
__skb_pull(skb, MPLS_HLEN);
skb_reset_mac_header(skb);
- /* mac_header_end() is used to locate the ethertype
+ /* skb_mpls_header() is used to locate the ethertype
* field correctly in the presence of VLAN tags.
*/
- hdr = (struct ethhdr *)(mac_header_end(skb) - ETH_HLEN);
+ hdr = (struct ethhdr *)(skb_mpls_header(skb) - ETH_HLEN);
hdr->h_proto = ethertype;
if (eth_p_mpls(skb->protocol))
skb->protocol = ethertype;
+
invalidate_flow_key(key);
return 0;
}
static int set_mpls(struct sk_buff *skb, struct sw_flow_key *key,
const __be32 *mpls_lse)
{
- __be32 *stack = (__be32 *)mac_header_end(skb);
+ __be32 *stack;
int err;
err = make_writable(skb, skb->mac_len + MPLS_HLEN);
if (unlikely(err))
return err;
+ stack = (__be32 *)skb_mpls_header(skb);
if (skb->ip_summed == CHECKSUM_COMPLETE) {
__be32 diff[] = { ~(*stack), *mpls_lse };
skb->csum = ~csum_partial((char *)diff, sizeof(diff),
/* push down current VLAN tag */
current_tag = vlan_tx_tag_get(skb);
- if (!__vlan_put_tag(skb, skb->vlan_proto, current_tag))
+ if (!vlan_insert_tag_set_proto(skb, skb->vlan_proto, current_tag))
return -ENOMEM;
-
/* Update mac_len for subsequent MPLS actions */
skb->mac_len += VLAN_HLEN;
if (memcmp(ipv6_key->ipv6_dst, daddr, sizeof(ipv6_key->ipv6_dst))) {
unsigned int offset = 0;
- int flags = OVS_IP6T_FH_F_SKIP_RH;
+ int flags = IP6_FH_F_SKIP_RH;
bool recalc_csum = true;
if (ipv6_ext_hdr(nh->nexthdr))
static int output_userspace(struct datapath *dp, struct sk_buff *skb,
struct sw_flow_key *key, const struct nlattr *attr)
{
+ struct ovs_tunnel_info info;
struct dp_upcall_info upcall;
const struct nlattr *a;
int rem;
- struct ovs_tunnel_info info;
upcall.cmd = OVS_PACKET_CMD_ACTION;
upcall.userdata = NULL;
return ovs_dp_upcall(dp, skb, key, &upcall);
}
-static bool last_action(const struct nlattr *a, int rem)
-{
- return a->nla_len == rem;
-}
-
static int sample(struct datapath *dp, struct sk_buff *skb,
struct sw_flow_key *key, const struct nlattr *attr)
{
* user space. This skb will be consumed by its caller.
*/
if (likely(nla_type(a) == OVS_ACTION_ATTR_USERSPACE &&
- last_action(a, rem)))
+ nla_is_last(a, rem)))
return output_userspace(dp, skb, key, a);
skb = skb_clone(skb, GFP_ATOMIC);
}
static int execute_recirc(struct datapath *dp, struct sk_buff *skb,
- struct sw_flow_key *key, const struct nlattr *a, int rem)
+ struct sw_flow_key *key,
+ const struct nlattr *a, int rem)
{
struct deferred_action *da;
err = ovs_flow_key_update(skb, key);
if (err)
return err;
-
}
BUG_ON(!is_flow_key_valid(key));
- if (!last_action(a, rem)) {
+ if (!nla_is_last(a, rem)) {
/* Recirc action is the not the last action
* of the action list, need to clone the skb.
*/
case OVS_ACTION_ATTR_RECIRC:
err = execute_recirc(dp, skb, key, a, rem);
- if (last_action(a, rem)) {
+ if (nla_is_last(a, rem)) {
/* If this is the last action, the skb has
* been consumed or freed.
* Return immediately.
do {
struct deferred_action *da = action_fifo_get(fifo);
struct sk_buff *skb = da->skb;
+ struct sw_flow_key *key = &da->pkt_key;
const struct nlattr *actions = da->actions;
if (actions)
- do_execute_actions(dp, skb, &da->pkt_key, actions,
+ do_execute_actions(dp, skb, key, actions,
nla_len(actions));
else
- ovs_dp_process_packet(skb, &da->pkt_key);
+ ovs_dp_process_packet(skb, key);
} while (!action_fifo_is_empty(fifo));
/* Reset FIFO for the next packet. */
/* Execute a list of actions against 'skb'. */
int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
- struct sw_flow_key *key,
- const struct sw_flow_actions *acts)
+ const struct sw_flow_actions *acts,
+ struct sw_flow_key *key)
{
int level = this_cpu_read(exec_actions_level);
int err;
}
this_cpu_inc(exec_actions_level);
-
- err = do_execute_actions(dp, skb, key, acts->actions, acts->actions_len);
+ err = do_execute_actions(dp, skb, key,
+ acts->actions, acts->actions_len);
if (!level)
process_deferred_actions(dp);