Skip to content

Commit

Permalink
Merge branch 'ovs-vport-cleanup'
Browse files Browse the repository at this point in the history
Pravin B Shelar says:

====================
openvswitch: Cleanup post vport conversion.

After converting all vport to netdev implmentations there
is no need for some of vport functionality.
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Aug 30, 2015
2 parents 8e816df + a581b96 commit 2573d78
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 202 deletions.
5 changes: 0 additions & 5 deletions net/openvswitch/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,10 +896,6 @@ static int execute_set_action(struct sk_buff *skb,
skb_dst_drop(skb);
dst_hold((struct dst_entry *)tun->tun_dst);
skb_dst_set(skb, (struct dst_entry *)tun->tun_dst);

/* FIXME: Remove when all vports have been converted */
OVS_CB(skb)->egress_tun_info = &tun->tun_dst->u.tun_info;

return 0;
}

Expand Down Expand Up @@ -1159,7 +1155,6 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
int err;

this_cpu_inc(exec_actions_level);
OVS_CB(skb)->egress_tun_info = NULL;
err = do_execute_actions(dp, skb, key,
acts->actions, acts->actions_len);

Expand Down
1 change: 0 additions & 1 deletion net/openvswitch/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,6 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
goto err_flow_free;

rcu_assign_pointer(flow->sf_acts, acts);
OVS_CB(packet)->egress_tun_info = NULL;
packet->priority = flow->key.phy.priority;
packet->mark = flow->key.phy.skb_mark;

Expand Down
5 changes: 0 additions & 5 deletions net/openvswitch/datapath.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "conntrack.h"
#include "flow.h"
#include "flow_table.h"
#include "vport.h"

#define DP_MAX_PORTS USHRT_MAX
#define DP_VPORT_HASH_BUCKETS 1024
Expand Down Expand Up @@ -94,15 +93,12 @@ struct datapath {

/**
* struct ovs_skb_cb - OVS data in skb CB
* @egress_tun_key: Tunnel information about this packet on egress path.
* NULL if the packet is not being tunneled.
* @input_vport: The original vport packet came in on. This value is cached
* when a packet is received by OVS.
* @mru: The maximum received fragement size; 0 if the packet is not
* fragmented.
*/
struct ovs_skb_cb {
struct ip_tunnel_info *egress_tun_info;
struct vport *input_vport;
u16 mru;
};
Expand Down Expand Up @@ -137,7 +133,6 @@ struct dp_upcall_info {
struct ovs_net {
struct list_head dps;
struct work_struct dp_notify_work;
struct vport_net vport_net;

/* Module reference for configuring conntrack. */
bool xt_label;
Expand Down
3 changes: 2 additions & 1 deletion net/openvswitch/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@
#include <net/mpls.h>
#include <net/ndisc.h>

#include "conntrack.h"
#include "datapath.h"
#include "flow.h"
#include "flow_netlink.h"
#include "conntrack.h"
#include "vport.h"

u64 ovs_flow_used_time(unsigned long flow_jiffies)
{
Expand Down
3 changes: 1 addition & 2 deletions net/openvswitch/vport-geneve.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ static int geneve_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,

return ovs_tunnel_get_egress_info(egress_tun_info,
ovs_dp_get_net(vport->dp),
OVS_CB(skb)->egress_tun_info,
IPPROTO_UDP, skb->mark, sport, dport);
skb, IPPROTO_UDP, sport, dport);
}

static struct vport *geneve_tnl_create(const struct vport_parms *parms)
Expand Down
3 changes: 1 addition & 2 deletions net/openvswitch/vport-gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ static int gre_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
{
return ovs_tunnel_get_egress_info(egress_tun_info,
ovs_dp_get_net(vport->dp),
OVS_CB(skb)->egress_tun_info,
IPPROTO_GRE, skb->mark, 0, 0);
skb, IPPROTO_GRE, 0, 0);
}

static struct vport_ops ovs_gre_vport_ops = {
Expand Down
57 changes: 25 additions & 32 deletions net/openvswitch/vport-internal_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,26 @@ static struct internal_dev *internal_dev_priv(struct net_device *netdev)
return netdev_priv(netdev);
}

/* This function is only called by the kernel network layer.*/
static struct rtnl_link_stats64 *internal_dev_get_stats(struct net_device *netdev,
struct rtnl_link_stats64 *stats)
{
struct vport *vport = ovs_internal_dev_get_vport(netdev);
struct ovs_vport_stats vport_stats;

ovs_vport_get_stats(vport, &vport_stats);

/* The tx and rx stats need to be swapped because the
* switch and host OS have opposite perspectives. */
stats->rx_packets = vport_stats.tx_packets;
stats->tx_packets = vport_stats.rx_packets;
stats->rx_bytes = vport_stats.tx_bytes;
stats->tx_bytes = vport_stats.rx_bytes;
stats->rx_errors = vport_stats.tx_errors;
stats->tx_errors = vport_stats.rx_errors;
stats->rx_dropped = vport_stats.tx_dropped;
stats->tx_dropped = vport_stats.rx_dropped;

return stats;
}

/* Called with rcu_read_lock_bh. */
static int internal_dev_xmit(struct sk_buff *skb, struct net_device *netdev)
{
int len, err;

len = skb->len;
rcu_read_lock();
ovs_vport_receive(internal_dev_priv(netdev)->vport, skb, NULL);
err = ovs_vport_receive(internal_dev_priv(netdev)->vport, skb, NULL);
rcu_read_unlock();

if (likely(!err)) {
struct pcpu_sw_netstats *tstats = this_cpu_ptr(netdev->tstats);

u64_stats_update_begin(&tstats->syncp);
tstats->tx_bytes += len;
tstats->tx_packets++;
u64_stats_update_end(&tstats->syncp);
} else {
netdev->stats.tx_errors++;
}
return 0;
}

Expand Down Expand Up @@ -121,7 +112,6 @@ static const struct net_device_ops internal_dev_netdev_ops = {
.ndo_start_xmit = internal_dev_xmit,
.ndo_set_mac_address = eth_mac_addr,
.ndo_change_mtu = internal_dev_change_mtu,
.ndo_get_stats64 = internal_dev_get_stats,
};

static struct rtnl_link_ops internal_dev_link_ops __read_mostly = {
Expand Down Expand Up @@ -212,18 +202,17 @@ static void internal_dev_destroy(struct vport *vport)
rtnl_unlock();
}

static int internal_dev_recv(struct vport *vport, struct sk_buff *skb)
static void internal_dev_recv(struct vport *vport, struct sk_buff *skb)
{
struct net_device *netdev = vport->dev;
int len;
struct pcpu_sw_netstats *stats;

if (unlikely(!(netdev->flags & IFF_UP))) {
kfree_skb(skb);
return 0;
netdev->stats.rx_dropped++;
return;
}

len = skb->len;

skb_dst_drop(skb);
nf_reset(skb);
secpath_reset(skb);
Expand All @@ -233,9 +222,13 @@ static int internal_dev_recv(struct vport *vport, struct sk_buff *skb)
skb->protocol = eth_type_trans(skb, netdev);
skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);

netif_rx(skb);
stats = this_cpu_ptr(netdev->tstats);
u64_stats_update_begin(&stats->syncp);
stats->rx_packets++;
stats->rx_bytes += skb->len;
u64_stats_update_end(&stats->syncp);

return len;
netif_rx(skb);
}

static struct vport_ops ovs_internal_vport_ops = {
Expand Down
22 changes: 8 additions & 14 deletions net/openvswitch/vport-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@
static struct vport_ops ovs_netdev_vport_ops;

/* Must be called with rcu_read_lock. */
static void netdev_port_receive(struct vport *vport, struct sk_buff *skb)
static void netdev_port_receive(struct sk_buff *skb)
{
struct vport *vport;

vport = ovs_netdev_get_vport(skb->dev);
if (unlikely(!vport))
goto error;

Expand All @@ -56,10 +59,8 @@ static void netdev_port_receive(struct vport *vport, struct sk_buff *skb)

skb_push(skb, ETH_HLEN);
ovs_skb_postpush_rcsum(skb, skb->data, ETH_HLEN);

ovs_vport_receive(vport, skb, skb_tunnel_info(skb));
return;

error:
kfree_skb(skb);
}
Expand All @@ -68,15 +69,11 @@ static void netdev_port_receive(struct vport *vport, struct sk_buff *skb)
static rx_handler_result_t netdev_frame_hook(struct sk_buff **pskb)
{
struct sk_buff *skb = *pskb;
struct vport *vport;

if (unlikely(skb->pkt_type == PACKET_LOOPBACK))
return RX_HANDLER_PASS;

vport = ovs_netdev_get_vport(skb->dev);

netdev_port_receive(vport, skb);

netdev_port_receive(skb);
return RX_HANDLER_CONSUMED;
}

Expand Down Expand Up @@ -203,27 +200,24 @@ static unsigned int packet_length(const struct sk_buff *skb)
return length;
}

int ovs_netdev_send(struct vport *vport, struct sk_buff *skb)
void ovs_netdev_send(struct vport *vport, struct sk_buff *skb)
{
int mtu = vport->dev->mtu;
int len;

if (unlikely(packet_length(skb) > mtu && !skb_is_gso(skb))) {
net_warn_ratelimited("%s: dropped over-mtu packet: %d > %d\n",
vport->dev->name,
packet_length(skb), mtu);
vport->dev->stats.tx_errors++;
goto drop;
}

skb->dev = vport->dev;
len = skb->len;
dev_queue_xmit(skb);

return len;
return;

drop:
kfree_skb(skb);
return 0;
}
EXPORT_SYMBOL_GPL(ovs_netdev_send);

Expand Down
2 changes: 1 addition & 1 deletion net/openvswitch/vport-netdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
struct vport *ovs_netdev_get_vport(struct net_device *dev);

struct vport *ovs_netdev_link(struct vport *vport, const char *name);
int ovs_netdev_send(struct vport *vport, struct sk_buff *skb);
void ovs_netdev_send(struct vport *vport, struct sk_buff *skb);
void ovs_netdev_detach_dev(struct vport *);

int __init ovs_netdev_init(void);
Expand Down
3 changes: 1 addition & 2 deletions net/openvswitch/vport-vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ static int vxlan_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
src_port = udp_flow_src_port(net, skb, 0, 0, true);

return ovs_tunnel_get_egress_info(egress_tun_info, net,
OVS_CB(skb)->egress_tun_info,
IPPROTO_UDP, skb->mark,
skb, IPPROTO_UDP,
src_port, dst_port);
}

Expand Down
Loading

0 comments on commit 2573d78

Please sign in to comment.