From: Jesse Gross <je...@nicira.com> OVS has quite a few global symbols that should be scoped with a prefix to prevent collisions with other modules in the kernel.
Suggested-by: Stephen Hemminger <shemmin...@vyatta.com> Signed-off-by: Justin Pettit <jpet...@nicira.com> --- net/openvswitch/actions.c | 6 +- net/openvswitch/datapath.c | 182 +++++++++++++++++----------------- net/openvswitch/datapath.h | 16 ++-- net/openvswitch/dp_notify.c | 17 ++-- net/openvswitch/flow.c | 66 ++++++------ net/openvswitch/flow.h | 54 +++++----- net/openvswitch/vport-internal_dev.c | 28 +++--- net/openvswitch/vport-internal_dev.h | 4 +- net/openvswitch/vport-netdev.c | 32 +++--- net/openvswitch/vport-netdev.h | 8 +- net/openvswitch/vport.c | 58 ++++++------ net/openvswitch/vport.h | 36 ++++---- 12 files changed, 254 insertions(+), 253 deletions(-) diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index e824dca..2725d1b 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -252,7 +252,7 @@ static int do_output(struct datapath *dp, struct sk_buff *skb, int out_port) return -ENODEV; } - vport_send(vport, skb); + ovs_vport_send(vport, skb); return 0; } @@ -281,7 +281,7 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb, } } - return dp_upcall(dp, skb, &upcall); + return ovs_dp_upcall(dp, skb, &upcall); } static int sample(struct datapath *dp, struct sk_buff *skb, @@ -406,7 +406,7 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, } /* Execute a list of actions against 'skb'. */ -int execute_actions(struct datapath *dp, struct sk_buff *skb) +int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb) { struct sw_flow_actions *acts = rcu_dereference(OVS_CB(skb)->flow->sf_acts); diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 62635e5..002e0a1 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c @@ -92,7 +92,7 @@ static struct datapath *get_dp(int dp_ifindex) rcu_read_lock(); dev = dev_get_by_index_rcu(&init_net, dp_ifindex); if (dev) { - struct vport *vport = internal_dev_get_vport(dev); + struct vport *vport = ovs_internal_dev_get_vport(dev); if (vport) dp = vport->dp; } @@ -102,7 +102,7 @@ static struct datapath *get_dp(int dp_ifindex) } /* Must be called with rcu_read_lock or RTNL lock. */ -const char *dp_name(const struct datapath *dp) +const char *ovs_dp_name(const struct datapath *dp) { struct vport *vport = rcu_dereference_rtnl(dp->ports[OVSP_LOCAL]); return vport->ops->get_name(vport); @@ -130,7 +130,7 @@ static void destroy_dp_rcu(struct rcu_head *rcu) { struct datapath *dp = container_of(rcu, struct datapath, rcu); - flow_tbl_destroy((__force struct flow_table *)dp->table); + ovs_flow_tbl_destroy((__force struct flow_table *)dp->table); free_percpu(dp->stats_percpu); kfree(dp); } @@ -140,7 +140,7 @@ static struct vport *new_vport(const struct vport_parms *parms) { struct vport *vport; - vport = vport_add(parms); + vport = ovs_vport_add(parms); if (!IS_ERR(vport)) { struct datapath *dp = parms->dp; @@ -152,7 +152,7 @@ static struct vport *new_vport(const struct vport_parms *parms) } /* Called with RTNL lock. */ -void dp_detach_port(struct vport *p) +void ovs_dp_detach_port(struct vport *p) { ASSERT_RTNL(); @@ -161,11 +161,11 @@ void dp_detach_port(struct vport *p) rcu_assign_pointer(p->dp->ports[p->port_no], NULL); /* Then destroy it. */ - vport_del(p); + ovs_vport_del(p); } /* Must be called with rcu_read_lock. */ -void dp_process_received_packet(struct vport *p, struct sk_buff *skb) +void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb) { struct datapath *dp = p->dp; struct sw_flow *flow; @@ -178,14 +178,14 @@ void dp_process_received_packet(struct vport *p, struct sk_buff *skb) stats = per_cpu_ptr(dp->stats_percpu, smp_processor_id()); /* Extract flow from 'skb' into 'key'. */ - error = flow_extract(skb, p->port_no, &key, &key_len); + error = ovs_flow_extract(skb, p->port_no, &key, &key_len); if (unlikely(error)) { kfree_skb(skb); return; } /* Look up flow. */ - flow = flow_tbl_lookup(rcu_dereference(dp->table), &key, key_len); + flow = ovs_flow_tbl_lookup(rcu_dereference(dp->table), &key, key_len); if (unlikely(!flow)) { struct dp_upcall_info upcall; @@ -193,7 +193,7 @@ void dp_process_received_packet(struct vport *p, struct sk_buff *skb) upcall.key = &key; upcall.userdata = NULL; upcall.pid = p->upcall_pid; - dp_upcall(dp, skb, &upcall); + ovs_dp_upcall(dp, skb, &upcall); consume_skb(skb); stats_counter = &stats->n_missed; goto out; @@ -202,8 +202,8 @@ void dp_process_received_packet(struct vport *p, struct sk_buff *skb) OVS_CB(skb)->flow = flow; stats_counter = &stats->n_hit; - flow_used(OVS_CB(skb)->flow, skb); - execute_actions(dp, skb); + ovs_flow_used(OVS_CB(skb)->flow, skb); + ovs_execute_actions(dp, skb); out: /* Update datapath statistics. */ @@ -220,7 +220,7 @@ static struct genl_family dp_packet_genl_family = { .maxattr = OVS_PACKET_ATTR_MAX }; -int dp_upcall(struct datapath *dp, struct sk_buff *skb, +int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb, const struct dp_upcall_info *upcall_info) { struct dp_stats_percpu *stats; @@ -277,7 +277,7 @@ static int queue_gso_packets(int dp_ifindex, struct sk_buff *skb, break; if (skb == segs && skb_shinfo(skb)->gso_type & SKB_GSO_UDP) { - /* The initial flow key extracted by flow_extract() in + /* The initial flow key extracted by ovs_flow_extract() in * this case is for a first fragment, so we need to * properly mark later fragments. */ @@ -347,7 +347,7 @@ static int queue_userspace_packet(int dp_ifindex, struct sk_buff *skb, upcall->dp_ifindex = dp_ifindex; nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_KEY); - flow_to_nlattrs(upcall_info->key, user_skb); + ovs_flow_to_nlattrs(upcall_info->key, user_skb); nla_nest_end(user_skb, nla); if (upcall_info->userdata) @@ -377,13 +377,13 @@ static int flush_flows(int dp_ifindex) return -ENODEV; old_table = genl_dereference(dp->table); - new_table = flow_tbl_alloc(TBL_MIN_BUCKETS); + new_table = ovs_flow_tbl_alloc(TBL_MIN_BUCKETS); if (!new_table) return -ENOMEM; rcu_assign_pointer(dp->table, new_table); - flow_tbl_deferred_destroy(old_table); + ovs_flow_tbl_deferred_destroy(old_table); return 0; } @@ -625,18 +625,18 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info) packet->protocol = htons(ETH_P_802_2); /* Build an sw_flow for sending this packet. */ - flow = flow_alloc(); + flow = ovs_flow_alloc(); err = PTR_ERR(flow); if (IS_ERR(flow)) goto err_kfree_skb; - err = flow_extract(packet, -1, &flow->key, &key_len); + err = ovs_flow_extract(packet, -1, &flow->key, &key_len); if (err) goto err_flow_free; - err = flow_metadata_from_nlattrs(&flow->key.phy.priority, - &flow->key.phy.in_port, - a[OVS_PACKET_ATTR_KEY]); + err = ovs_flow_metadata_from_nlattrs(&flow->key.phy.priority, + &flow->key.phy.in_port, + a[OVS_PACKET_ATTR_KEY]); if (err) goto err_flow_free; @@ -644,9 +644,9 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info) if (err) goto err_flow_free; - flow->hash = flow_hash(&flow->key, key_len); + flow->hash = ovs_flow_hash(&flow->key, key_len); - acts = flow_actions_alloc(a[OVS_PACKET_ATTR_ACTIONS]); + acts = ovs_flow_actions_alloc(a[OVS_PACKET_ATTR_ACTIONS]); err = PTR_ERR(acts); if (IS_ERR(acts)) goto err_flow_free; @@ -662,17 +662,17 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info) goto err_unlock; local_bh_disable(); - err = execute_actions(dp, packet); + err = ovs_execute_actions(dp, packet); local_bh_enable(); rcu_read_unlock(); - flow_free(flow); + ovs_flow_free(flow); return err; err_unlock: rcu_read_unlock(); err_flow_free: - flow_free(flow); + ovs_flow_free(flow); err_kfree_skb: kfree_skb(packet); err: @@ -698,7 +698,7 @@ static void get_dp_stats(struct datapath *dp, struct ovs_dp_stats *stats) int i; struct flow_table *table = genl_dereference(dp->table); - stats->n_flows = flow_tbl_count(table); + stats->n_flows = ovs_flow_tbl_count(table); stats->n_hit = stats->n_missed = stats->n_lost = 0; for_each_possible_cpu(i) { @@ -733,7 +733,7 @@ static struct genl_family dp_flow_genl_family = { .maxattr = OVS_FLOW_ATTR_MAX }; -static struct genl_multicast_group dp_flow_multicast_group = { +static struct genl_multicast_group ovs_dp_flow_multicast_group = { .name = OVS_FLOW_MCGROUP }; @@ -763,7 +763,7 @@ static int ovs_flow_cmd_fill_info(struct sw_flow *flow, struct datapath *dp, nla = nla_nest_start(skb, OVS_FLOW_ATTR_KEY); if (!nla) goto nla_put_failure; - err = flow_to_nlattrs(&flow->key, skb); + err = ovs_flow_to_nlattrs(&flow->key, skb); if (err) goto error; nla_nest_end(skb, nla); @@ -776,7 +776,7 @@ static int ovs_flow_cmd_fill_info(struct sw_flow *flow, struct datapath *dp, spin_unlock_bh(&flow->lock); if (used) - NLA_PUT_U64(skb, OVS_FLOW_ATTR_USED, flow_used_time(used)); + NLA_PUT_U64(skb, OVS_FLOW_ATTR_USED, ovs_flow_used_time(used)); if (stats.n_packets) NLA_PUT(skb, OVS_FLOW_ATTR_STATS, @@ -865,7 +865,7 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) error = -EINVAL; if (!a[OVS_FLOW_ATTR_KEY]) goto error; - error = flow_from_nlattrs(&key, &key_len, a[OVS_FLOW_ATTR_KEY]); + error = ovs_flow_from_nlattrs(&key, &key_len, a[OVS_FLOW_ATTR_KEY]); if (error) goto error; @@ -885,7 +885,7 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) goto error; table = genl_dereference(dp->table); - flow = flow_tbl_lookup(table, &key, key_len); + flow = ovs_flow_tbl_lookup(table, &key, key_len); if (!flow) { struct sw_flow_actions *acts; @@ -895,19 +895,19 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) goto error; /* Expand table, if necessary, to make room. */ - if (flow_tbl_need_to_expand(table)) { + if (ovs_flow_tbl_need_to_expand(table)) { struct flow_table *new_table; - new_table = flow_tbl_expand(table); + new_table = ovs_flow_tbl_expand(table); if (!IS_ERR(new_table)) { rcu_assign_pointer(dp->table, new_table); - flow_tbl_deferred_destroy(table); + ovs_flow_tbl_deferred_destroy(table); table = genl_dereference(dp->table); } } /* Allocate flow. */ - flow = flow_alloc(); + flow = ovs_flow_alloc(); if (IS_ERR(flow)) { error = PTR_ERR(flow); goto error; @@ -916,15 +916,15 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) clear_stats(flow); /* Obtain actions. */ - acts = flow_actions_alloc(a[OVS_FLOW_ATTR_ACTIONS]); + acts = ovs_flow_actions_alloc(a[OVS_FLOW_ATTR_ACTIONS]); error = PTR_ERR(acts); if (IS_ERR(acts)) goto error_free_flow; rcu_assign_pointer(flow->sf_acts, acts); /* Put flow in bucket. */ - flow->hash = flow_hash(&key, key_len); - flow_tbl_insert(table, flow); + flow->hash = ovs_flow_hash(&key, key_len); + ovs_flow_tbl_insert(table, flow); reply = ovs_flow_cmd_build_info(flow, dp, info->snd_pid, info->snd_seq, @@ -955,13 +955,13 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) old_acts->actions_len))) { struct sw_flow_actions *new_acts; - new_acts = flow_actions_alloc(acts_attrs); + new_acts = ovs_flow_actions_alloc(acts_attrs); error = PTR_ERR(new_acts); if (IS_ERR(new_acts)) goto error; rcu_assign_pointer(flow->sf_acts, new_acts); - flow_deferred_free_acts(old_acts); + ovs_flow_deferred_free_acts(old_acts); } reply = ovs_flow_cmd_build_info(flow, dp, info->snd_pid, @@ -977,14 +977,15 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) if (!IS_ERR(reply)) genl_notify(reply, genl_info_net(info), info->snd_pid, - dp_flow_multicast_group.id, info->nlhdr, GFP_KERNEL); + ovs_dp_flow_multicast_group.id, info->nlhdr, + GFP_KERNEL); else netlink_set_err(init_net.genl_sock, 0, - dp_flow_multicast_group.id, PTR_ERR(reply)); + ovs_dp_flow_multicast_group.id, PTR_ERR(reply)); return 0; error_free_flow: - flow_free(flow); + ovs_flow_free(flow); error: return error; } @@ -1003,7 +1004,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info) if (!a[OVS_FLOW_ATTR_KEY]) return -EINVAL; - err = flow_from_nlattrs(&key, &key_len, a[OVS_FLOW_ATTR_KEY]); + err = ovs_flow_from_nlattrs(&key, &key_len, a[OVS_FLOW_ATTR_KEY]); if (err) return err; @@ -1012,7 +1013,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info) return -ENODEV; table = genl_dereference(dp->table); - flow = flow_tbl_lookup(table, &key, key_len); + flow = ovs_flow_tbl_lookup(table, &key, key_len); if (!flow) return -ENOENT; @@ -1038,7 +1039,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) if (!a[OVS_FLOW_ATTR_KEY]) return flush_flows(ovs_header->dp_ifindex); - err = flow_from_nlattrs(&key, &key_len, a[OVS_FLOW_ATTR_KEY]); + err = ovs_flow_from_nlattrs(&key, &key_len, a[OVS_FLOW_ATTR_KEY]); if (err) return err; @@ -1047,7 +1048,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) return -ENODEV; table = genl_dereference(dp->table); - flow = flow_tbl_lookup(table, &key, key_len); + flow = ovs_flow_tbl_lookup(table, &key, key_len); if (!flow) return -ENOENT; @@ -1055,16 +1056,16 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) if (!reply) return -ENOMEM; - flow_tbl_remove(table, flow); + ovs_flow_tbl_remove(table, flow); err = ovs_flow_cmd_fill_info(flow, dp, reply, info->snd_pid, info->snd_seq, 0, OVS_FLOW_CMD_DEL); BUG_ON(err < 0); - flow_deferred_free(flow); + ovs_flow_deferred_free(flow); genl_notify(reply, genl_info_net(info), info->snd_pid, - dp_flow_multicast_group.id, info->nlhdr, GFP_KERNEL); + ovs_dp_flow_multicast_group.id, info->nlhdr, GFP_KERNEL); return 0; } @@ -1086,7 +1087,7 @@ static int ovs_flow_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb) bucket = cb->args[0]; obj = cb->args[1]; - flow = flow_tbl_next(table, &bucket, &obj); + flow = ovs_flow_tbl_next(table, &bucket, &obj); if (!flow) break; @@ -1139,7 +1140,7 @@ static struct genl_family dp_datapath_genl_family = { .maxattr = OVS_DP_ATTR_MAX }; -static struct genl_multicast_group dp_datapath_multicast_group = { +static struct genl_multicast_group ovs_dp_datapath_multicast_group = { .name = OVS_DATAPATH_MCGROUP }; @@ -1158,7 +1159,7 @@ static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb, ovs_header->dp_ifindex = get_dpifindex(dp); rcu_read_lock(); - err = nla_put_string(skb, OVS_DP_ATTR_NAME, dp_name(dp)); + err = nla_put_string(skb, OVS_DP_ATTR_NAME, ovs_dp_name(dp)); rcu_read_unlock(); if (err) goto nla_put_failure; @@ -1204,7 +1205,7 @@ static struct datapath *lookup_datapath(struct ovs_header *ovs_header, struct vport *vport; rcu_read_lock(); - vport = vport_locate(nla_data(a[OVS_DP_ATTR_NAME])); + vport = ovs_vport_locate(nla_data(a[OVS_DP_ATTR_NAME])); dp = vport && vport->port_no == OVSP_LOCAL ? vport->dp : NULL; rcu_read_unlock(); } @@ -1237,7 +1238,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info) /* Allocate table. */ err = -ENOMEM; - rcu_assign_pointer(dp->table, flow_tbl_alloc(TBL_MIN_BUCKETS)); + rcu_assign_pointer(dp->table, ovs_flow_tbl_alloc(TBL_MIN_BUCKETS)); if (!dp->table) goto err_free_dp; @@ -1274,15 +1275,16 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info) rtnl_unlock(); genl_notify(reply, genl_info_net(info), info->snd_pid, - dp_datapath_multicast_group.id, info->nlhdr, GFP_KERNEL); + ovs_dp_datapath_multicast_group.id, info->nlhdr, + GFP_KERNEL); return 0; err_destroy_local_port: - dp_detach_port(rtnl_dereference(dp->ports[OVSP_LOCAL])); + ovs_dp_detach_port(rtnl_dereference(dp->ports[OVSP_LOCAL])); err_destroy_percpu: free_percpu(dp->stats_percpu); err_destroy_table: - flow_tbl_destroy(genl_dereference(dp->table)); + ovs_flow_tbl_destroy(genl_dereference(dp->table)); err_free_dp: kfree(dp); err_put_module: @@ -1314,10 +1316,10 @@ static int ovs_dp_cmd_del(struct sk_buff *skb, struct genl_info *info) list_for_each_entry_safe(vport, next_vport, &dp->port_list, node) if (vport->port_no != OVSP_LOCAL) - dp_detach_port(vport); + ovs_dp_detach_port(vport); list_del(&dp->list_node); - dp_detach_port(rtnl_dereference(dp->ports[OVSP_LOCAL])); + ovs_dp_detach_port(rtnl_dereference(dp->ports[OVSP_LOCAL])); /* rtnl_unlock() will wait until all the references to devices that * are pending unregistration have been dropped. We do it here to @@ -1330,7 +1332,8 @@ static int ovs_dp_cmd_del(struct sk_buff *skb, struct genl_info *info) module_put(THIS_MODULE); genl_notify(reply, genl_info_net(info), info->snd_pid, - dp_datapath_multicast_group.id, info->nlhdr, GFP_KERNEL); + ovs_dp_datapath_multicast_group.id, info->nlhdr, + GFP_KERNEL); return 0; @@ -1354,12 +1357,14 @@ static int ovs_dp_cmd_set(struct sk_buff *skb, struct genl_info *info) if (IS_ERR(reply)) { err = PTR_ERR(reply); netlink_set_err(init_net.genl_sock, 0, - dp_datapath_multicast_group.id, err); + ovs_dp_datapath_multicast_group.id, err); return 0; } genl_notify(reply, genl_info_net(info), info->snd_pid, - dp_datapath_multicast_group.id, info->nlhdr, GFP_KERNEL); + ovs_dp_datapath_multicast_group.id, info->nlhdr, + GFP_KERNEL); + return 0; } @@ -1442,7 +1447,7 @@ static struct genl_family dp_vport_genl_family = { .maxattr = OVS_VPORT_ATTR_MAX }; -struct genl_multicast_group dp_vport_multicast_group = { +struct genl_multicast_group ovs_dp_vport_multicast_group = { .name = OVS_VPORT_MCGROUP }; @@ -1466,11 +1471,11 @@ static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb, NLA_PUT_STRING(skb, OVS_VPORT_ATTR_NAME, vport->ops->get_name(vport)); NLA_PUT_U32(skb, OVS_VPORT_ATTR_UPCALL_PID, vport->upcall_pid); - vport_get_stats(vport, &vport_stats); + ovs_vport_get_stats(vport, &vport_stats); NLA_PUT(skb, OVS_VPORT_ATTR_STATS, sizeof(struct ovs_vport_stats), &vport_stats); - err = vport_get_options(vport, skb); + err = ovs_vport_get_options(vport, skb); if (err == -EMSGSIZE) goto error; @@ -1510,7 +1515,7 @@ static struct vport *lookup_vport(struct ovs_header *ovs_header, struct vport *vport; if (a[OVS_VPORT_ATTR_NAME]) { - vport = vport_locate(nla_data(a[OVS_VPORT_ATTR_NAME])); + vport = ovs_vport_locate(nla_data(a[OVS_VPORT_ATTR_NAME])); if (!vport) return ERR_PTR(-ENODEV); return vport; @@ -1593,12 +1598,11 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info) OVS_VPORT_CMD_NEW); if (IS_ERR(reply)) { err = PTR_ERR(reply); - dp_detach_port(vport); + ovs_dp_detach_port(vport); goto exit_unlock; } genl_notify(reply, genl_info_net(info), info->snd_pid, - dp_vport_multicast_group.id, info->nlhdr, GFP_KERNEL); - + ovs_dp_vport_multicast_group.id, info->nlhdr, GFP_KERNEL); exit_unlock: rtnl_unlock(); @@ -1625,7 +1629,7 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info) err = -EINVAL; if (!err && a[OVS_VPORT_ATTR_OPTIONS]) - err = vport_set_options(vport, a[OVS_VPORT_ATTR_OPTIONS]); + err = ovs_vport_set_options(vport, a[OVS_VPORT_ATTR_OPTIONS]); if (!err && a[OVS_VPORT_ATTR_UPCALL_PID]) vport->upcall_pid = nla_get_u32(a[OVS_VPORT_ATTR_UPCALL_PID]); @@ -1634,12 +1638,12 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info) if (IS_ERR(reply)) { err = PTR_ERR(reply); netlink_set_err(init_net.genl_sock, 0, - dp_vport_multicast_group.id, err); + ovs_dp_vport_multicast_group.id, err); return 0; } genl_notify(reply, genl_info_net(info), info->snd_pid, - dp_vport_multicast_group.id, info->nlhdr, GFP_KERNEL); + ovs_dp_vport_multicast_group.id, info->nlhdr, GFP_KERNEL); exit_unlock: rtnl_unlock(); @@ -1670,10 +1674,10 @@ static int ovs_vport_cmd_del(struct sk_buff *skb, struct genl_info *info) if (IS_ERR(reply)) goto exit_unlock; - dp_detach_port(vport); + ovs_dp_detach_port(vport); genl_notify(reply, genl_info_net(info), info->snd_pid, - dp_vport_multicast_group.id, info->nlhdr, GFP_KERNEL); + ovs_dp_vport_multicast_group.id, info->nlhdr, GFP_KERNEL); exit_unlock: rtnl_unlock(); @@ -1775,13 +1779,13 @@ struct genl_family_and_ops { static const struct genl_family_and_ops dp_genl_families[] = { { &dp_datapath_genl_family, dp_datapath_genl_ops, ARRAY_SIZE(dp_datapath_genl_ops), - &dp_datapath_multicast_group }, + &ovs_dp_datapath_multicast_group }, { &dp_vport_genl_family, dp_vport_genl_ops, ARRAY_SIZE(dp_vport_genl_ops), - &dp_vport_multicast_group }, + &ovs_dp_vport_multicast_group }, { &dp_flow_genl_family, dp_flow_genl_ops, ARRAY_SIZE(dp_flow_genl_ops), - &dp_flow_multicast_group }, + &ovs_dp_flow_multicast_group }, { &dp_packet_genl_family, dp_packet_genl_ops, ARRAY_SIZE(dp_packet_genl_ops), NULL }, @@ -1834,15 +1838,15 @@ static int __init dp_init(void) pr_info("Open vSwitch switching datapath\n"); - err = flow_init(); + err = ovs_flow_init(); if (err) goto error; - err = vport_init(); + err = ovs_vport_init(); if (err) goto error_flow_exit; - err = register_netdevice_notifier(&dp_device_notifier); + err = register_netdevice_notifier(&ovs_dp_device_notifier); if (err) goto error_vport_exit; @@ -1853,11 +1857,11 @@ static int __init dp_init(void) return 0; error_unreg_notifier: - unregister_netdevice_notifier(&dp_device_notifier); + unregister_netdevice_notifier(&ovs_dp_device_notifier); error_vport_exit: - vport_exit(); + ovs_vport_exit(); error_flow_exit: - flow_exit(); + ovs_flow_exit(); error: return err; } @@ -1866,9 +1870,9 @@ static void dp_cleanup(void) { rcu_barrier(); dp_unregister_genl(ARRAY_SIZE(dp_genl_families)); - unregister_netdevice_notifier(&dp_device_notifier); - vport_exit(); - flow_exit(); + unregister_netdevice_notifier(&ovs_dp_device_notifier); + ovs_vport_exit(); + ovs_flow_exit(); } module_init(dp_init); diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h index f0f65e6..5b9f884 100644 --- a/net/openvswitch/datapath.h +++ b/net/openvswitch/datapath.h @@ -109,17 +109,17 @@ struct dp_upcall_info { u32 pid; }; -extern struct notifier_block dp_device_notifier; -extern struct genl_multicast_group dp_vport_multicast_group; +extern struct notifier_block ovs_dp_device_notifier; +extern struct genl_multicast_group ovs_dp_vport_multicast_group; -void dp_process_received_packet(struct vport *, struct sk_buff *); -void dp_detach_port(struct vport *); -int dp_upcall(struct datapath *, struct sk_buff *, - const struct dp_upcall_info *); +void ovs_dp_process_received_packet(struct vport *, struct sk_buff *); +void ovs_dp_detach_port(struct vport *); +int ovs_dp_upcall(struct datapath *, struct sk_buff *, + const struct dp_upcall_info *); -const char *dp_name(const struct datapath *dp); +const char *ovs_dp_name(const struct datapath *dp); struct sk_buff *ovs_vport_cmd_build_info(struct vport *, u32 pid, u32 seq, u8 cmd); -int execute_actions(struct datapath *dp, struct sk_buff *skb); +int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb); #endif /* datapath.h */ diff --git a/net/openvswitch/dp_notify.c b/net/openvswitch/dp_notify.c index be1a539..4673651 100644 --- a/net/openvswitch/dp_notify.c +++ b/net/openvswitch/dp_notify.c @@ -29,39 +29,38 @@ static int dp_device_event(struct notifier_block *unused, unsigned long event, struct net_device *dev = ptr; struct vport *vport; - if (is_internal_dev(dev)) - vport = internal_dev_get_vport(dev); + if (ovs_is_internal_dev(dev)) + vport = ovs_internal_dev_get_vport(dev); else - vport = netdev_get_vport(dev); + vport = ovs_netdev_get_vport(dev); if (!vport) return NOTIFY_DONE; switch (event) { case NETDEV_UNREGISTER: - if (!is_internal_dev(dev)) { + if (!ovs_is_internal_dev(dev)) { struct sk_buff *notify; notify = ovs_vport_cmd_build_info(vport, 0, 0, OVS_VPORT_CMD_DEL); - dp_detach_port(vport); + ovs_dp_detach_port(vport); if (IS_ERR(notify)) { netlink_set_err(init_net.genl_sock, 0, - dp_vport_multicast_group.id, + ovs_dp_vport_multicast_group.id, PTR_ERR(notify)); break; } - genlmsg_multicast(notify, 0, dp_vport_multicast_group.id, + genlmsg_multicast(notify, 0, ovs_dp_vport_multicast_group.id, GFP_KERNEL); } break; - } return NOTIFY_DONE; } -struct notifier_block dp_device_notifier = { +struct notifier_block ovs_dp_device_notifier = { .notifier_call = dp_device_event }; diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c index e5553dc..0209f7c 100644 --- a/net/openvswitch/flow.c +++ b/net/openvswitch/flow.c @@ -109,7 +109,7 @@ static bool icmphdr_ok(struct sk_buff *skb) sizeof(struct icmphdr)); } -u64 flow_used_time(unsigned long flow_jiffies) +u64 ovs_flow_used_time(unsigned long flow_jiffies) { struct timespec cur_ts; u64 cur_ms, idle_ms; @@ -232,7 +232,7 @@ static bool icmp6hdr_ok(struct sk_buff *skb) #define TCP_FLAGS_OFFSET 13 #define TCP_FLAG_MASK 0x3f -void flow_used(struct sw_flow *flow, struct sk_buff *skb) +void ovs_flow_used(struct sw_flow *flow, struct sk_buff *skb) { u8 tcp_flags = 0; @@ -250,7 +250,7 @@ void flow_used(struct sw_flow *flow, struct sk_buff *skb) spin_unlock(&flow->lock); } -struct sw_flow_actions *flow_actions_alloc(const struct nlattr *actions) +struct sw_flow_actions *ovs_flow_actions_alloc(const struct nlattr *actions) { int actions_len = nla_len(actions); struct sw_flow_actions *sfa; @@ -270,7 +270,7 @@ struct sw_flow_actions *flow_actions_alloc(const struct nlattr *actions) return sfa; } -struct sw_flow *flow_alloc(void) +struct sw_flow *ovs_flow_alloc(void) { struct sw_flow *flow; @@ -318,7 +318,7 @@ static void free_buckets(struct flex_array *buckets) flex_array_free(buckets); } -struct flow_table *flow_tbl_alloc(int new_size) +struct flow_table *ovs_flow_tbl_alloc(int new_size) { struct flow_table *table = kmalloc(sizeof(*table), GFP_KERNEL); @@ -337,7 +337,7 @@ struct flow_table *flow_tbl_alloc(int new_size) return table; } -void flow_tbl_destroy(struct flow_table *table) +void ovs_flow_tbl_destroy(struct flow_table *table) { int i; @@ -351,7 +351,7 @@ void flow_tbl_destroy(struct flow_table *table) hlist_for_each_entry_safe(flow, node, n, head, hash_node) { hlist_del_init_rcu(&flow->hash_node); - flow_free(flow); + ovs_flow_free(flow); } } @@ -363,10 +363,10 @@ static void flow_tbl_destroy_rcu_cb(struct rcu_head *rcu) { struct flow_table *table = container_of(rcu, struct flow_table, rcu); - flow_tbl_destroy(table); + ovs_flow_tbl_destroy(table); } -void flow_tbl_deferred_destroy(struct flow_table *table) +void ovs_flow_tbl_deferred_destroy(struct flow_table *table) { if (!table) return; @@ -374,7 +374,7 @@ void flow_tbl_deferred_destroy(struct flow_table *table) call_rcu(&table->rcu, flow_tbl_destroy_rcu_cb); } -struct sw_flow *flow_tbl_next(struct flow_table *table, u32 *bucket, u32 *last) +struct sw_flow *ovs_flow_tbl_next(struct flow_table *table, u32 *bucket, u32 *last) { struct sw_flow *flow; struct hlist_head *head; @@ -399,13 +399,13 @@ struct sw_flow *flow_tbl_next(struct flow_table *table, u32 *bucket, u32 *last) return NULL; } -struct flow_table *flow_tbl_expand(struct flow_table *table) +struct flow_table *ovs_flow_tbl_expand(struct flow_table *table) { struct flow_table *new_table; int n_buckets = table->n_buckets * 2; int i; - new_table = flow_tbl_alloc(n_buckets); + new_table = ovs_flow_tbl_alloc(n_buckets); if (!new_table) return ERR_PTR(-ENOMEM); @@ -418,14 +418,14 @@ struct flow_table *flow_tbl_expand(struct flow_table *table) hlist_for_each_entry_safe(flow, n, pos, head, hash_node) { hlist_del_init_rcu(&flow->hash_node); - flow_tbl_insert(new_table, flow); + ovs_flow_tbl_insert(new_table, flow); } } return new_table; } -void flow_free(struct sw_flow *flow) +void ovs_flow_free(struct sw_flow *flow) { if (unlikely(!flow)) return; @@ -434,22 +434,22 @@ void flow_free(struct sw_flow *flow) kmem_cache_free(flow_cache, flow); } -/* RCU callback used by flow_deferred_free. */ +/* RCU callback used by ovs_flow_deferred_free. */ static void rcu_free_flow_callback(struct rcu_head *rcu) { struct sw_flow *flow = container_of(rcu, struct sw_flow, rcu); - flow_free(flow); + ovs_flow_free(flow); } /* Schedules 'flow' to be freed after the next RCU grace period. * The caller must hold rcu_read_lock for this to be sensible. */ -void flow_deferred_free(struct sw_flow *flow) +void ovs_flow_deferred_free(struct sw_flow *flow) { call_rcu(&flow->rcu, rcu_free_flow_callback); } -/* RCU callback used by flow_deferred_free_acts. */ +/* RCU callback used by ovs_flow_deferred_free_acts. */ static void rcu_free_acts_callback(struct rcu_head *rcu) { struct sw_flow_actions *sf_acts = container_of(rcu, @@ -459,7 +459,7 @@ static void rcu_free_acts_callback(struct rcu_head *rcu) /* Schedules 'sf_acts' to be freed after the next RCU grace period. * The caller must hold rcu_read_lock for this to be sensible. */ -void flow_deferred_free_acts(struct sw_flow_actions *sf_acts) +void ovs_flow_deferred_free_acts(struct sw_flow_actions *sf_acts) { call_rcu(&sf_acts->rcu, rcu_free_acts_callback); } @@ -603,7 +603,7 @@ out: } /** - * flow_extract - extracts a flow key from an Ethernet frame. + * ovs_flow_extract - extracts a flow key from an Ethernet frame. * @skb: sk_buff that contains the frame, with skb->data pointing to the * Ethernet header * @in_port: port number on which @skb was received. @@ -626,7 +626,7 @@ out: * of a correct length, otherwise the same as skb->network_header. * For other key->dl_type values it is left untouched. */ -int flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key, +int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key, int *key_lenp) { int error = 0; @@ -792,12 +792,12 @@ out: return error; } -u32 flow_hash(const struct sw_flow_key *key, int key_len) +u32 ovs_flow_hash(const struct sw_flow_key *key, int key_len) { return jhash2((u32 *)key, DIV_ROUND_UP(key_len, sizeof(u32)), hash_seed); } -struct sw_flow *flow_tbl_lookup(struct flow_table *table, +struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *table, struct sw_flow_key *key, int key_len) { struct sw_flow *flow; @@ -805,7 +805,7 @@ struct sw_flow *flow_tbl_lookup(struct flow_table *table, struct hlist_head *head; u32 hash; - hash = flow_hash(key, key_len); + hash = ovs_flow_hash(key, key_len); head = find_bucket(table, hash); hlist_for_each_entry_rcu(flow, n, head, hash_node) { @@ -818,7 +818,7 @@ struct sw_flow *flow_tbl_lookup(struct flow_table *table, return NULL; } -void flow_tbl_insert(struct flow_table *table, struct sw_flow *flow) +void ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow) { struct hlist_head *head; @@ -827,7 +827,7 @@ void flow_tbl_insert(struct flow_table *table, struct sw_flow *flow) table->count++; } -void flow_tbl_remove(struct flow_table *table, struct sw_flow *flow) +void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow) { if (!hlist_unhashed(&flow->hash_node)) { hlist_del_init_rcu(&flow->hash_node); @@ -990,13 +990,13 @@ static int parse_flow_nlattrs(const struct nlattr *attr, } /** - * flow_from_nlattrs - parses Netlink attributes into a flow key. + * ovs_flow_from_nlattrs - parses Netlink attributes into a flow key. * @swkey: receives the extracted flow key. * @key_lenp: number of bytes used in @swkey. * @attr: Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink attribute * sequence. */ -int flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, +int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, const struct nlattr *attr) { const struct nlattr *a[OVS_KEY_ATTR_MAX + 1]; @@ -1151,7 +1151,7 @@ int flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, } /** - * flow_metadata_from_nlattrs - parses Netlink attributes into a flow key. + * ovs_flow_metadata_from_nlattrs - parses Netlink attributes into a flow key. * @in_port: receives the extracted input port. * @key: Netlink attribute holding nested %OVS_KEY_ATTR_* Netlink attribute * sequence. @@ -1161,7 +1161,7 @@ int flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, * get the metadata, that is, the parts of the flow key that cannot be * extracted from the packet itself. */ -int flow_metadata_from_nlattrs(u32 *priority, u16 *in_port, +int ovs_flow_metadata_from_nlattrs(u32 *priority, u16 *in_port, const struct nlattr *attr) { const struct nlattr *nla; @@ -1195,7 +1195,7 @@ int flow_metadata_from_nlattrs(u32 *priority, u16 *in_port, return 0; } -int flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb) +int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey, struct sk_buff *skb) { struct ovs_key_ethernet *eth_key; struct nlattr *nla, *encap; @@ -1354,7 +1354,7 @@ nla_put_failure: /* Initializes the flow module. * Returns zero if successful or a negative error code. */ -int flow_init(void) +int ovs_flow_init(void) { flow_cache = kmem_cache_create("sw_flow", sizeof(struct sw_flow), 0, 0, NULL); @@ -1367,7 +1367,7 @@ int flow_init(void) } /* Uninitializes the flow module. */ -void flow_exit(void) +void ovs_flow_exit(void) { kmem_cache_destroy(flow_cache); } diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h index b98596f..3f0c06c 100644 --- a/net/openvswitch/flow.h +++ b/net/openvswitch/flow.h @@ -122,20 +122,20 @@ struct arp_eth_header { unsigned char ar_tip[4]; /* target IP address */ } __packed; -int flow_init(void); -void flow_exit(void); +int ovs_flow_init(void); +void ovs_flow_exit(void); -struct sw_flow *flow_alloc(void); -void flow_deferred_free(struct sw_flow *); -void flow_free(struct sw_flow *flow); +struct sw_flow *ovs_flow_alloc(void); +void ovs_flow_deferred_free(struct sw_flow *); +void ovs_flow_free(struct sw_flow *flow); -struct sw_flow_actions *flow_actions_alloc(const struct nlattr *); -void flow_deferred_free_acts(struct sw_flow_actions *); +struct sw_flow_actions *ovs_flow_actions_alloc(const struct nlattr *); +void ovs_flow_deferred_free_acts(struct sw_flow_actions *); -int flow_extract(struct sk_buff *, u16 in_port, struct sw_flow_key *, - int *key_lenp); -void flow_used(struct sw_flow *, struct sk_buff *); -u64 flow_used_time(unsigned long flow_jiffies); +int ovs_flow_extract(struct sk_buff *, u16 in_port, struct sw_flow_key *, + int *key_lenp); +void ovs_flow_used(struct sw_flow *, struct sk_buff *); +u64 ovs_flow_used_time(unsigned long flow_jiffies); /* Upper bound on the length of a nlattr-formatted flow key. The longest * nlattr-formatted flow key would be: @@ -155,10 +155,10 @@ u64 flow_used_time(unsigned long flow_jiffies); */ #define FLOW_BUFSIZE 132 -int flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *); -int flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, +int ovs_flow_to_nlattrs(const struct sw_flow_key *, struct sk_buff *); +int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, const struct nlattr *); -int flow_metadata_from_nlattrs(u32 *priority, u16 *in_port, +int ovs_flow_metadata_from_nlattrs(u32 *priority, u16 *in_port, const struct nlattr *); #define TBL_MIN_BUCKETS 1024 @@ -169,27 +169,27 @@ struct flow_table { struct rcu_head rcu; }; -static inline int flow_tbl_count(struct flow_table *table) +static inline int ovs_flow_tbl_count(struct flow_table *table) { return table->count; } -static inline int flow_tbl_need_to_expand(struct flow_table *table) +static inline int ovs_flow_tbl_need_to_expand(struct flow_table *table) { return (table->count > table->n_buckets); } -struct sw_flow *flow_tbl_lookup(struct flow_table *table, - struct sw_flow_key *key, int len); -void flow_tbl_destroy(struct flow_table *table); -void flow_tbl_deferred_destroy(struct flow_table *table); -struct flow_table *flow_tbl_alloc(int new_size); -struct flow_table *flow_tbl_expand(struct flow_table *table); -void flow_tbl_insert(struct flow_table *table, struct sw_flow *flow); -void flow_tbl_remove(struct flow_table *table, struct sw_flow *flow); -u32 flow_hash(const struct sw_flow_key *key, int key_len); - -struct sw_flow *flow_tbl_next(struct flow_table *table, u32 *bucket, u32 *idx); +struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *table, + struct sw_flow_key *key, int len); +void ovs_flow_tbl_destroy(struct flow_table *table); +void ovs_flow_tbl_deferred_destroy(struct flow_table *table); +struct flow_table *ovs_flow_tbl_alloc(int new_size); +struct flow_table *ovs_flow_tbl_expand(struct flow_table *table); +void ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow); +void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow); +u32 ovs_flow_hash(const struct sw_flow_key *key, int key_len); + +struct sw_flow *ovs_flow_tbl_next(struct flow_table *table, u32 *bucket, u32 *idx); extern const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1]; #endif /* flow.h */ diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c index 89f7be4..8fc28b8 100644 --- a/net/openvswitch/vport-internal_dev.c +++ b/net/openvswitch/vport-internal_dev.c @@ -42,10 +42,10 @@ static struct internal_dev *internal_dev_priv(struct net_device *netdev) static struct rtnl_link_stats64 *internal_dev_get_stats(struct net_device *netdev, struct rtnl_link_stats64 *stats) { - struct vport *vport = internal_dev_get_vport(netdev); + struct vport *vport = ovs_internal_dev_get_vport(netdev); struct ovs_vport_stats vport_stats; - vport_get_stats(vport, &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. */ @@ -75,7 +75,7 @@ static int internal_dev_mac_addr(struct net_device *dev, void *p) static int internal_dev_xmit(struct sk_buff *skb, struct net_device *netdev) { rcu_read_lock(); - vport_receive(internal_dev_priv(netdev)->vport, skb); + ovs_vport_receive(internal_dev_priv(netdev)->vport, skb); rcu_read_unlock(); return 0; } @@ -114,9 +114,9 @@ static int internal_dev_change_mtu(struct net_device *netdev, int new_mtu) static void internal_dev_destructor(struct net_device *dev) { - struct vport *vport = internal_dev_get_vport(dev); + struct vport *vport = ovs_internal_dev_get_vport(dev); - vport_free(vport); + ovs_vport_free(vport); free_netdev(dev); } @@ -156,8 +156,8 @@ static struct vport *internal_dev_create(const struct vport_parms *parms) struct internal_dev *internal_dev; int err; - vport = vport_alloc(sizeof(struct netdev_vport), - &internal_vport_ops, parms); + vport = ovs_vport_alloc(sizeof(struct netdev_vport), + &ovs_internal_vport_ops, parms); if (IS_ERR(vport)) { err = PTR_ERR(vport); goto error; @@ -187,7 +187,7 @@ static struct vport *internal_dev_create(const struct vport_parms *parms) error_free_netdev: free_netdev(netdev_vport->dev); error_free_vport: - vport_free(vport); + ovs_vport_free(vport); error: return ERR_PTR(err); } @@ -218,23 +218,23 @@ static int internal_dev_recv(struct vport *vport, struct sk_buff *skb) return len; } -const struct vport_ops internal_vport_ops = { +const struct vport_ops ovs_internal_vport_ops = { .type = OVS_VPORT_TYPE_INTERNAL, .create = internal_dev_create, .destroy = internal_dev_destroy, - .get_name = netdev_get_name, - .get_ifindex = netdev_get_ifindex, + .get_name = ovs_netdev_get_name, + .get_ifindex = ovs_netdev_get_ifindex, .send = internal_dev_recv, }; -int is_internal_dev(const struct net_device *netdev) +int ovs_is_internal_dev(const struct net_device *netdev) { return netdev->netdev_ops == &internal_dev_netdev_ops; } -struct vport *internal_dev_get_vport(struct net_device *netdev) +struct vport *ovs_internal_dev_get_vport(struct net_device *netdev) { - if (!is_internal_dev(netdev)) + if (!ovs_is_internal_dev(netdev)) return NULL; return internal_dev_priv(netdev)->vport; diff --git a/net/openvswitch/vport-internal_dev.h b/net/openvswitch/vport-internal_dev.h index 91002cb..3454447 100644 --- a/net/openvswitch/vport-internal_dev.h +++ b/net/openvswitch/vport-internal_dev.h @@ -22,7 +22,7 @@ #include "datapath.h" #include "vport.h" -int is_internal_dev(const struct net_device *); -struct vport *internal_dev_get_vport(struct net_device *); +int ovs_is_internal_dev(const struct net_device *); +struct vport *ovs_internal_dev_get_vport(struct net_device *); #endif /* vport-internal_dev.h */ diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c index 2aa4814..c1068ae 100644 --- a/net/openvswitch/vport-netdev.c +++ b/net/openvswitch/vport-netdev.c @@ -49,7 +49,7 @@ static void netdev_port_receive(struct vport *vport, struct sk_buff *skb) return; skb_push(skb, ETH_HLEN); - vport_receive(vport, skb); + ovs_vport_receive(vport, skb); } /* Called with rcu_read_lock and bottom-halves disabled. */ @@ -61,7 +61,7 @@ static rx_handler_result_t netdev_frame_hook(struct sk_buff **pskb) if (unlikely(skb->pkt_type == PACKET_LOOPBACK)) return RX_HANDLER_PASS; - vport = netdev_get_vport(skb->dev); + vport = ovs_netdev_get_vport(skb->dev); netdev_port_receive(vport, skb); @@ -74,8 +74,8 @@ static struct vport *netdev_create(const struct vport_parms *parms) struct netdev_vport *netdev_vport; int err; - vport = vport_alloc(sizeof(struct netdev_vport), - &netdev_vport_ops, parms); + vport = ovs_vport_alloc(sizeof(struct netdev_vport), + &ovs_netdev_vport_ops, parms); if (IS_ERR(vport)) { err = PTR_ERR(vport); goto error; @@ -91,7 +91,7 @@ static struct vport *netdev_create(const struct vport_parms *parms) if (netdev_vport->dev->flags & IFF_LOOPBACK || netdev_vport->dev->type != ARPHRD_ETHER || - is_internal_dev(netdev_vport->dev)) { + ovs_is_internal_dev(netdev_vport->dev)) { err = -EINVAL; goto error_put; } @@ -109,7 +109,7 @@ static struct vport *netdev_create(const struct vport_parms *parms) error_put: dev_put(netdev_vport->dev); error_free_vport: - vport_free(vport); + ovs_vport_free(vport); error: return ERR_PTR(err); } @@ -125,22 +125,21 @@ static void netdev_destroy(struct vport *vport) synchronize_rcu(); dev_put(netdev_vport->dev); - vport_free(vport); + ovs_vport_free(vport); } -const char *netdev_get_name(const struct vport *vport) +const char *ovs_netdev_get_name(const struct vport *vport) { const struct netdev_vport *netdev_vport = netdev_vport_priv(vport); return netdev_vport->dev->name; } -int netdev_get_ifindex(const struct vport *vport) +int ovs_netdev_get_ifindex(const struct vport *vport) { const struct netdev_vport *netdev_vport = netdev_vport_priv(vport); return netdev_vport->dev->ifindex; } - static unsigned packet_length(const struct sk_buff *skb) { unsigned length = skb->len - ETH_HLEN; @@ -160,7 +159,7 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb) if (unlikely(packet_length(skb) > mtu && !skb_is_gso(skb))) { if (net_ratelimit()) pr_warn("%s: dropped over-mtu packet: %d > %d\n", - dp_name(vport->dp), packet_length(skb), mtu); + ovs_dp_name(vport->dp), packet_length(skb), mtu); goto error; } @@ -175,12 +174,12 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb) error: kfree_skb(skb); - vport_record_error(vport, VPORT_E_TX_DROPPED); + ovs_vport_record_error(vport, VPORT_E_TX_DROPPED); return 0; } /* Returns null if this device is not attached to a datapath. */ -struct vport *netdev_get_vport(struct net_device *dev) +struct vport *ovs_netdev_get_vport(struct net_device *dev) { if (likely(dev->priv_flags & IFF_OVS_DATAPATH)) return (struct vport *) @@ -189,12 +188,11 @@ struct vport *netdev_get_vport(struct net_device *dev) return NULL; } -const struct vport_ops netdev_vport_ops = { +const struct vport_ops ovs_netdev_vport_ops = { .type = OVS_VPORT_TYPE_NETDEV, .create = netdev_create, .destroy = netdev_destroy, - .get_name = netdev_get_name, - .get_ifindex = netdev_get_ifindex, + .get_name = ovs_netdev_get_name, + .get_ifindex = ovs_netdev_get_ifindex, .send = netdev_send, }; - diff --git a/net/openvswitch/vport-netdev.h b/net/openvswitch/vport-netdev.h index 6cc8719..fd9b008 100644 --- a/net/openvswitch/vport-netdev.h +++ b/net/openvswitch/vport-netdev.h @@ -23,7 +23,7 @@ #include "vport.h" -struct vport *netdev_get_vport(struct net_device *dev); +struct vport *ovs_netdev_get_vport(struct net_device *dev); struct netdev_vport { struct net_device *dev; @@ -35,8 +35,8 @@ netdev_vport_priv(const struct vport *vport) return vport_priv(vport); } -const char *netdev_get_name(const struct vport *); -const char *netdev_get_config(const struct vport *); -int netdev_get_ifindex(const struct vport *); +const char *ovs_netdev_get_name(const struct vport *); +const char *ovs_netdev_get_config(const struct vport *); +int ovs_netdev_get_ifindex(const struct vport *); #endif /* vport_netdev.h */ diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c index 0332312..6cd7601 100644 --- a/net/openvswitch/vport.c +++ b/net/openvswitch/vport.c @@ -35,8 +35,8 @@ /* List of statically compiled vport implementations. Don't forget to also * add yours to the list at the bottom of vport.h. */ static const struct vport_ops *vport_ops_list[] = { - &netdev_vport_ops, - &internal_vport_ops, + &ovs_netdev_vport_ops, + &ovs_internal_vport_ops, }; /* Protected by RCU read lock for reading, RTNL lock for writing. */ @@ -44,11 +44,11 @@ static struct hlist_head *dev_table; #define VPORT_HASH_BUCKETS 1024 /** - * vport_init - initialize vport subsystem + * ovs_vport_init - initialize vport subsystem * * Called at module load time to initialize the vport subsystem. */ -int vport_init(void) +int ovs_vport_init(void) { dev_table = kzalloc(VPORT_HASH_BUCKETS * sizeof(struct hlist_head), GFP_KERNEL); @@ -59,11 +59,11 @@ int vport_init(void) } /** - * vport_exit - shutdown vport subsystem + * ovs_vport_exit - shutdown vport subsystem * * Called at module exit time to shutdown the vport subsystem. */ -void vport_exit(void) +void ovs_vport_exit(void) { kfree(dev_table); } @@ -75,13 +75,13 @@ static struct hlist_head *hash_bucket(const char *name) } /** - * vport_locate - find a port that has already been created + * ovs_vport_locate - find a port that has already been created * * @name: name of port to find * * Must be called with RTNL or RCU read lock. */ -struct vport *vport_locate(const char *name) +struct vport *ovs_vport_locate(const char *name) { struct hlist_head *bucket = hash_bucket(name); struct vport *vport; @@ -95,7 +95,7 @@ struct vport *vport_locate(const char *name) } /** - * vport_alloc - allocate and initialize new vport + * ovs_vport_alloc - allocate and initialize new vport * * @priv_size: Size of private data area to allocate. * @ops: vport device ops @@ -105,7 +105,7 @@ struct vport *vport_locate(const char *name) * vport_priv(). vports that are no longer needed should be released with * vport_free(). */ -struct vport *vport_alloc(int priv_size, const struct vport_ops *ops, +struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops, const struct vport_parms *parms) { struct vport *vport; @@ -136,7 +136,7 @@ struct vport *vport_alloc(int priv_size, const struct vport_ops *ops, } /** - * vport_free - uninitialize and free vport + * ovs_vport_free - uninitialize and free vport * * @vport: vport to free * @@ -145,21 +145,21 @@ struct vport *vport_alloc(int priv_size, const struct vport_ops *ops, * The caller must ensure that an RCU grace period has passed since the last * time @vport was in a datapath. */ -void vport_free(struct vport *vport) +void ovs_vport_free(struct vport *vport) { free_percpu(vport->percpu_stats); kfree(vport); } /** - * vport_add - add vport device (for kernel callers) + * ovs_vport_add - add vport device (for kernel callers) * * @parms: Information about new vport. * * Creates a new vport with the specified configuration (which is dependent on * device type). RTNL lock must be held. */ -struct vport *vport_add(const struct vport_parms *parms) +struct vport *ovs_vport_add(const struct vport_parms *parms) { struct vport *vport; int err = 0; @@ -188,7 +188,7 @@ out: } /** - * vport_set_options - modify existing vport device (for kernel callers) + * ovs_vport_set_options - modify existing vport device (for kernel callers) * * @vport: vport to modify. * @port: New configuration. @@ -196,7 +196,7 @@ out: * Modifies an existing device with the specified configuration (which is * dependent on device type). RTNL lock must be held. */ -int vport_set_options(struct vport *vport, struct nlattr *options) +int ovs_vport_set_options(struct vport *vport, struct nlattr *options) { ASSERT_RTNL(); @@ -206,14 +206,14 @@ int vport_set_options(struct vport *vport, struct nlattr *options) } /** - * vport_del - delete existing vport device + * ovs_vport_del - delete existing vport device * * @vport: vport to delete. * * Detaches @vport from its datapath and destroys it. It is possible to fail * for reasons such as lack of memory. RTNL lock must be held. */ -void vport_del(struct vport *vport) +void ovs_vport_del(struct vport *vport) { ASSERT_RTNL(); @@ -223,7 +223,7 @@ void vport_del(struct vport *vport) } /** - * vport_get_stats - retrieve device stats + * ovs_vport_get_stats - retrieve device stats * * @vport: vport from which to retrieve the stats * @stats: location to store stats @@ -232,7 +232,7 @@ void vport_del(struct vport *vport) * * Must be called with RTNL lock or rcu_read_lock. */ -void vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats) +void ovs_vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats) { int i; @@ -276,7 +276,7 @@ void vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats) } /** - * vport_get_options - retrieve device options + * ovs_vport_get_options - retrieve device options * * @vport: vport from which to retrieve the options. * @skb: sk_buff where options should be appended. @@ -291,7 +291,7 @@ void vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats) * * Must be called with RTNL lock or rcu_read_lock. */ -int vport_get_options(const struct vport *vport, struct sk_buff *skb) +int ovs_vport_get_options(const struct vport *vport, struct sk_buff *skb) { struct nlattr *nla; @@ -312,7 +312,7 @@ int vport_get_options(const struct vport *vport, struct sk_buff *skb) } /** - * vport_receive - pass up received packet to the datapath for processing + * ovs_vport_receive - pass up received packet to the datapath for processing * * @vport: vport that received the packet * @skb: skb that was received @@ -321,7 +321,7 @@ int vport_get_options(const struct vport *vport, struct sk_buff *skb) * skb->data should point to the Ethernet header. The caller must have already * called compute_ip_summed() to initialize the checksumming fields. */ -void vport_receive(struct vport *vport, struct sk_buff *skb) +void ovs_vport_receive(struct vport *vport, struct sk_buff *skb) { struct vport_percpu_stats *stats; @@ -332,11 +332,11 @@ void vport_receive(struct vport *vport, struct sk_buff *skb) stats->rx_bytes += skb->len; u64_stats_update_end(&stats->sync); - dp_process_received_packet(vport, skb); + ovs_dp_process_received_packet(vport, skb); } /** - * vport_send - send a packet on a device + * ovs_vport_send - send a packet on a device * * @vport: vport on which to send the packet * @skb: skb to send @@ -344,7 +344,7 @@ void vport_receive(struct vport *vport, struct sk_buff *skb) * Sends the given packet and returns the length of data sent. Either RTNL * lock or rcu_read_lock must be held. */ -int vport_send(struct vport *vport, struct sk_buff *skb) +int ovs_vport_send(struct vport *vport, struct sk_buff *skb) { int sent = vport->ops->send(vport, skb); @@ -362,7 +362,7 @@ int vport_send(struct vport *vport, struct sk_buff *skb) } /** - * vport_record_error - indicate device error to generic stats layer + * ovs_vport_record_error - indicate device error to generic stats layer * * @vport: vport that encountered the error * @err_type: one of enum vport_err_type types to indicate the error type @@ -370,7 +370,7 @@ int vport_send(struct vport *vport, struct sk_buff *skb) * If using the vport generic stats layer indicate that an error of the given * type has occured. */ -void vport_record_error(struct vport *vport, enum vport_err_type err_type) +void ovs_vport_record_error(struct vport *vport, enum vport_err_type err_type) { spin_lock(&vport->stats_lock); diff --git a/net/openvswitch/vport.h b/net/openvswitch/vport.h index da093cd..1960962 100644 --- a/net/openvswitch/vport.h +++ b/net/openvswitch/vport.h @@ -32,20 +32,20 @@ struct vport_parms; /* The following definitions are for users of the vport subsytem: */ -int vport_init(void); -void vport_exit(void); +int ovs_vport_init(void); +void ovs_vport_exit(void); -struct vport *vport_add(const struct vport_parms *); -void vport_del(struct vport *); +struct vport *ovs_vport_add(const struct vport_parms *); +void ovs_vport_del(struct vport *); -struct vport *vport_locate(const char *name); +struct vport *ovs_vport_locate(const char *name); -void vport_get_stats(struct vport *, struct ovs_vport_stats *); +void ovs_vport_get_stats(struct vport *, struct ovs_vport_stats *); -int vport_set_options(struct vport *, struct nlattr *options); -int vport_get_options(const struct vport *, struct sk_buff *); +int ovs_vport_set_options(struct vport *, struct nlattr *options); +int ovs_vport_get_options(const struct vport *, struct sk_buff *); -int vport_send(struct vport *, struct sk_buff *); +int ovs_vport_send(struct vport *, struct sk_buff *); /* The following definitions are for implementers of vport devices: */ @@ -109,7 +109,7 @@ struct vport_parms { enum ovs_vport_type type; struct nlattr *options; - /* For vport_alloc(). */ + /* For ovs_vport_alloc(). */ struct datapath *dp; u16 port_no; u32 upcall_pid; @@ -120,7 +120,7 @@ struct vport_parms { * * @type: %OVS_VPORT_TYPE_* value for this type of virtual port. * @create: Create a new vport configured as specified. On success returns - * a new vport allocated with vport_alloc(), otherwise an ERR_PTR() value. + * a new vport allocated with ovs_vport_alloc(), otherwise an ERR_PTR() value. * @destroy: Destroys a vport. Must call vport_free() on the vport but not * before an RCU grace period has elapsed. * @set_options: Modify the configuration of an existing vport. May be %NULL @@ -159,9 +159,9 @@ enum vport_err_type { VPORT_E_TX_ERROR, }; -struct vport *vport_alloc(int priv_size, const struct vport_ops *, - const struct vport_parms *); -void vport_free(struct vport *); +struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *, + const struct vport_parms *); +void ovs_vport_free(struct vport *); #define VPORT_ALIGN 8 @@ -194,12 +194,12 @@ static inline struct vport *vport_from_priv(const void *priv) return (struct vport *)(priv - ALIGN(sizeof(struct vport), VPORT_ALIGN)); } -void vport_receive(struct vport *, struct sk_buff *); -void vport_record_error(struct vport *, enum vport_err_type err_type); +void ovs_vport_receive(struct vport *, struct sk_buff *); +void ovs_vport_record_error(struct vport *, enum vport_err_type err_type); /* List of statically compiled vport implementations. Don't forget to also * add yours to the list at the top of vport.c. */ -extern const struct vport_ops netdev_vport_ops; -extern const struct vport_ops internal_vport_ops; +extern const struct vport_ops ovs_netdev_vport_ops; +extern const struct vport_ops ovs_internal_vport_ops; #endif /* vport.h */ -- 1.7.4.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev