Skip to content

Commit

Permalink
datapath: Prevent linker error of unknown symbol.
Browse files Browse the repository at this point in the history
With the latest change of separating vports into their own modules,
it is necessary to export all public functions in linux/compat/
directory.  Also, we should prefix functions which replace the
upstream ones with 'rpl_' and others with 'ovs_'.  This will prevent
the linker error when vport modules use those functions in the future.
e.g., the to be merged vport-stt module will use the flex_array_*
functions which are not currently exported.

Co-authored-by: Tuan Nguyen <[email protected]>
Signed-off-by: Alex Wang <[email protected]>
Acked-by: Jesse Gross <[email protected]>
  • Loading branch information
yew011 and tuannguyen1991 committed Apr 26, 2015
1 parent 2985381 commit bedf02f
Show file tree
Hide file tree
Showing 35 changed files with 237 additions and 162 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ Thomas Lacroix [email protected]
Todd Deshane [email protected]
Tom Everman [email protected]
Tsvi Slonim [email protected]
Tuan Nguyen [email protected]
Tyler Coumbes [email protected]
Valient Gough [email protected]
Vivien Bernet-Rollande [email protected]
Expand Down
20 changes: 12 additions & 8 deletions datapath/linux/compat/dev-openvswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void dev_disable_lro(struct net_device *dev) { }
static int nr_bridges;

#ifdef HAVE_RHEL_OVS_HOOK
int netdev_rx_handler_register(struct net_device *dev,
openvswitch_handle_frame_hook_t *hook,
void *rx_handler_data)
int rpl_netdev_rx_handler_register(struct net_device *dev,
openvswitch_handle_frame_hook_t *hook,
void *rx_handler_data)
{
nr_bridges++;
rcu_assign_pointer(dev->ax25_ptr, rx_handler_data);
Expand All @@ -50,12 +50,13 @@ int netdev_rx_handler_register(struct net_device *dev,
rcu_assign_pointer(openvswitch_handle_frame_hook, hook);
return 0;
}
EXPORT_SYMBOL_GPL(rpl_netdev_rx_handler_register);
#else

int netdev_rx_handler_register(struct net_device *dev,
struct sk_buff *(*hook)(struct net_bridge_port *p,
struct sk_buff *skb),
void *rx_handler_data)
int rpl_netdev_rx_handler_register(struct net_device *dev,
struct sk_buff *(*hook)(struct net_bridge_port *p,
struct sk_buff *skb),
void *rx_handler_data)
{
nr_bridges++;
if (dev->br_port)
Expand All @@ -67,9 +68,10 @@ int netdev_rx_handler_register(struct net_device *dev,
br_handle_frame_hook = hook;
return 0;
}
EXPORT_SYMBOL_GPL(rpl_netdev_rx_handler_register);
#endif

void netdev_rx_handler_unregister(struct net_device *dev)
void rpl_netdev_rx_handler_unregister(struct net_device *dev)
{
nr_bridges--;
#ifdef HAVE_RHEL_OVS_HOOK
Expand All @@ -88,4 +90,6 @@ void netdev_rx_handler_unregister(struct net_device *dev)
br_handle_frame_hook = NULL;
#endif
}
EXPORT_SYMBOL_GPL(rpl_netdev_rx_handler_unregister);

#endif
2 changes: 2 additions & 0 deletions datapath/linux/compat/exthdrs_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ int rpl_ipv6_skip_exthdr(const struct sk_buff *skb, int start,
*nexthdrp = nexthdr;
return start;
}
EXPORT_SYMBOL_GPL(rpl_ipv6_skip_exthdr);
#endif /* Kernel version < 3.3 */

#ifndef HAVE_IP6_FH_F_SKIP_RH
Expand Down Expand Up @@ -169,5 +170,6 @@ int rpl_ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
*offset = start;
return nexthdr;
}
EXPORT_SYMBOL_GPL(rpl_ipv6_find_hdr);

#endif
27 changes: 18 additions & 9 deletions datapath/linux/compat/flex_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static inline int elements_fit_in_base(struct flex_array *fa)
* capacity in the base structure. Also note that no effort is made
* to efficiently pack objects across page boundaries.
*/
struct flex_array *flex_array_alloc(int element_size, unsigned int total,
struct flex_array *rpl_flex_array_alloc(int element_size, unsigned int total,
gfp_t flags)
{
struct flex_array *ret;
Expand Down Expand Up @@ -118,6 +118,7 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total,
FLEX_ARRAY_BASE_BYTES_LEFT);
return ret;
}
EXPORT_SYMBOL_GPL(rpl_flex_array_alloc);

static int fa_element_to_part_nr(struct flex_array *fa,
unsigned int element_nr)
Expand All @@ -132,7 +133,7 @@ static int fa_element_to_part_nr(struct flex_array *fa,
* This is to be used in cases where the base 'struct flex_array'
* has been statically allocated and should not be free.
*/
void flex_array_free_parts(struct flex_array *fa)
void rpl_flex_array_free_parts(struct flex_array *fa)
{
int part_nr;

Expand All @@ -141,12 +142,14 @@ void flex_array_free_parts(struct flex_array *fa)
for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++)
kfree(fa->parts[part_nr]);
}
EXPORT_SYMBOL_GPL(rpl_flex_array_free_parts);

void flex_array_free(struct flex_array *fa)
void rpl_flex_array_free(struct flex_array *fa)
{
flex_array_free_parts(fa);
kfree(fa);
}
EXPORT_SYMBOL_GPL(rpl_flex_array_free);

static unsigned int index_inside_part(struct flex_array *fa,
unsigned int element_nr,
Expand Down Expand Up @@ -191,7 +194,7 @@ __fa_get_part(struct flex_array *fa, int part_nr, gfp_t flags)
*
* Locking must be provided by the caller.
*/
int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src,
int rpl_flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src,
gfp_t flags)
{
int part_nr = 0;
Expand All @@ -214,6 +217,7 @@ int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src,
memcpy(dst, src, fa->element_size);
return 0;
}
EXPORT_SYMBOL_GPL(rpl_flex_array_put);

/**
* flex_array_clear - clear element in array at @element_nr
Expand All @@ -222,7 +226,7 @@ int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src,
*
* Locking must be provided by the caller.
*/
int flex_array_clear(struct flex_array *fa, unsigned int element_nr)
int rpl_flex_array_clear(struct flex_array *fa, unsigned int element_nr)
{
int part_nr = 0;
struct flex_array_part *part;
Expand All @@ -244,6 +248,7 @@ int flex_array_clear(struct flex_array *fa, unsigned int element_nr)
memset(dst, FLEX_ARRAY_FREE, fa->element_size);
return 0;
}
EXPORT_SYMBOL_GPL(rpl_flex_array_clear);

/**
* flex_array_prealloc - guarantee that array space exists
Expand All @@ -260,7 +265,7 @@ int flex_array_clear(struct flex_array *fa, unsigned int element_nr)
*
* Locking must be provided by the caller.
*/
int flex_array_prealloc(struct flex_array *fa, unsigned int start,
int rpl_flex_array_prealloc(struct flex_array *fa, unsigned int start,
unsigned int nr_elements, gfp_t flags)
{
int start_part;
Expand Down Expand Up @@ -293,6 +298,7 @@ int flex_array_prealloc(struct flex_array *fa, unsigned int start,
}
return 0;
}
EXPORT_SYMBOL_GPL(rpl_flex_array_prealloc);

/**
* flex_array_get - pull data back out of the array
Expand All @@ -306,7 +312,7 @@ int flex_array_prealloc(struct flex_array *fa, unsigned int start,
*
* Locking must be provided by the caller.
*/
void *flex_array_get(struct flex_array *fa, unsigned int element_nr)
void *rpl_flex_array_get(struct flex_array *fa, unsigned int element_nr)
{
int part_nr = 0;
struct flex_array_part *part;
Expand All @@ -325,6 +331,7 @@ void *flex_array_get(struct flex_array *fa, unsigned int element_nr)
}
return &part->elements[index_inside_part(fa, element_nr, part_nr)];
}
EXPORT_SYMBOL_GPL(rpl_flex_array_get);

/**
* flex_array_get_ptr - pull a ptr back out of the array
Expand All @@ -335,7 +342,7 @@ void *flex_array_get(struct flex_array *fa, unsigned int element_nr)
* flex_array_put_ptr(). This function should not be called if the
* element in question was not set using the _put_ptr() helper.
*/
void *flex_array_get_ptr(struct flex_array *fa, unsigned int element_nr)
void *rpl_flex_array_get_ptr(struct flex_array *fa, unsigned int element_nr)
{
void **tmp;

Expand All @@ -345,6 +352,7 @@ void *flex_array_get_ptr(struct flex_array *fa, unsigned int element_nr)

return *tmp;
}
EXPORT_SYMBOL_GPL(rpl_flex_array_get_ptr);

static int part_is_free(struct flex_array_part *part)
{
Expand All @@ -365,7 +373,7 @@ static int part_is_free(struct flex_array_part *part)
*
* Locking must be provided by the caller.
*/
int flex_array_shrink(struct flex_array *fa)
int rpl_flex_array_shrink(struct flex_array *fa)
{
struct flex_array_part *part;
int part_nr;
Expand All @@ -387,5 +395,6 @@ int flex_array_shrink(struct flex_array *fa)
}
return ret;
}
EXPORT_SYMBOL_GPL(rpl_flex_array_shrink);

#endif /* Linux version < 3.0.0 */
5 changes: 3 additions & 2 deletions datapath/linux/compat/flow_dissector.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static __always_inline u32 __flow_hash_3words(u32 a, u32 b, u32 c)
return jhash_3words(a, b, c, hashrnd);
}

u32 __skb_get_hash(struct sk_buff *skb)
u32 rpl__skb_get_rxhash(struct sk_buff *skb)
{
struct flow_keys keys;
u32 hash;
Expand All @@ -231,5 +231,6 @@ u32 __skb_get_hash(struct sk_buff *skb)
#endif
return hash;
}
EXPORT_SYMBOL_GPL(__skb_get_hash);
EXPORT_SYMBOL_GPL(rpl__skb_get_rxhash);

#endif
3 changes: 3 additions & 0 deletions datapath/linux/compat/genetlink-openvswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void rpl_genl_notify(struct rpl_genl_family *family, struct sk_buff *skb,
genl_notify(skb, net, portid, group, nlh, flags);
#endif
}
EXPORT_SYMBOL_GPL(rpl_genl_notify);

int rpl___genl_register_family(struct rpl_genl_family *f)
{
Expand Down Expand Up @@ -52,4 +53,6 @@ int rpl___genl_register_family(struct rpl_genl_family *f)
return err;

}
EXPORT_SYMBOL_GPL(rpl___genl_register_family);

#endif /* kernel version < 3.13.0 */
24 changes: 12 additions & 12 deletions datapath/linux/compat/geneve.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ static void geneve_build_header(struct genevehdr *geneveh,
*
* This function will add other UDP tunnel headers.
*/
int geneve_xmit_skb(struct geneve_sock *gs, struct rtable *rt,
struct sk_buff *skb, __be32 src, __be32 dst, __u8 tos,
__u8 ttl, __be16 df, __be16 src_port, __be16 dst_port,
__be16 tun_flags, u8 vni[3], u8 opt_len, u8 *opt,
bool csum, bool xnet)
int rpl_geneve_xmit_skb(struct geneve_sock *gs, struct rtable *rt,
struct sk_buff *skb, __be32 src, __be32 dst, __u8 tos,
__u8 ttl, __be16 df, __be16 src_port, __be16 dst_port,
__be16 tun_flags, u8 vni[3], u8 opt_len, u8 *opt,
bool csum, bool xnet)
{
struct genevehdr *gnvh;
int min_headroom;
Expand Down Expand Up @@ -118,7 +118,7 @@ int geneve_xmit_skb(struct geneve_sock *gs, struct rtable *rt,
tos, ttl, df, src_port, dst_port, xnet,
!csum);
}
EXPORT_SYMBOL_GPL(geneve_xmit_skb);
EXPORT_SYMBOL_GPL(rpl_geneve_xmit_skb);

/* Callback from net/ipv4/udp.c to receive packets */
static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
Expand Down Expand Up @@ -221,13 +221,13 @@ static struct geneve_sock *geneve_socket_create(struct net *net, __be16 port,
return gs;
}

struct geneve_sock *geneve_sock_add(struct net *net, __be16 port,
geneve_rcv_t *rcv, void *data,
bool no_share, bool ipv6)
struct geneve_sock *rpl_geneve_sock_add(struct net *net, __be16 port,
geneve_rcv_t *rcv, void *data,
bool no_share, bool ipv6)
{
return geneve_socket_create(net, port, rcv, data, ipv6);
}
EXPORT_SYMBOL_GPL(geneve_sock_add);
EXPORT_SYMBOL_GPL(rpl_geneve_sock_add);

static void rcu_free_gs(struct rcu_head *rcu)
{
Expand All @@ -236,9 +236,9 @@ static void rcu_free_gs(struct rcu_head *rcu)
kfree(gs);
}

void geneve_sock_release(struct geneve_sock *gs)
void rpl_geneve_sock_release(struct geneve_sock *gs)
{
udp_tunnel_sock_release(gs->sock);
call_rcu(&gs->rcu, rcu_free_gs);
}
EXPORT_SYMBOL_GPL(geneve_sock_release);
EXPORT_SYMBOL_GPL(rpl_geneve_sock_release);
16 changes: 8 additions & 8 deletions datapath/linux/compat/gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static const struct gre_protocol ipgre_protocol = {
.handler = gre_cisco_rcv,
};

int gre_cisco_register(struct gre_cisco_protocol *newp)
int rpl_gre_cisco_register(struct gre_cisco_protocol *newp)
{
int err;

Expand All @@ -250,9 +250,9 @@ int gre_cisco_register(struct gre_cisco_protocol *newp)
return (cmpxchg((struct gre_cisco_protocol **)&gre_cisco_proto, NULL, newp) == NULL) ?
0 : -EBUSY;
}
EXPORT_SYMBOL_GPL(gre_cisco_register);
EXPORT_SYMBOL_GPL(rpl_gre_cisco_register);

int gre_cisco_unregister(struct gre_cisco_protocol *proto)
int rpl_gre_cisco_unregister(struct gre_cisco_protocol *proto)
{
int ret;

Expand All @@ -266,7 +266,7 @@ int gre_cisco_unregister(struct gre_cisco_protocol *proto)
ret = gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO);
return ret;
}
EXPORT_SYMBOL_GPL(gre_cisco_unregister);
EXPORT_SYMBOL_GPL(rpl_gre_cisco_unregister);

#endif /* !HAVE_GRE_CISCO_REGISTER */

Expand All @@ -287,7 +287,7 @@ static void gre_csum_fix(struct sk_buff *skb)
skb->len - gre_offset, 0));
}

struct sk_buff *gre_handle_offloads(struct sk_buff *skb, bool gre_csum)
struct sk_buff *rpl_gre_handle_offloads(struct sk_buff *skb, bool gre_csum)
{
int type = gre_csum ? SKB_GSO_GRE_CSUM : SKB_GSO_GRE;
gso_fix_segment_t fix_segment;
Expand All @@ -299,14 +299,14 @@ struct sk_buff *gre_handle_offloads(struct sk_buff *skb, bool gre_csum)

return ovs_iptunnel_handle_offloads(skb, gre_csum, type, fix_segment);
}
EXPORT_SYMBOL_GPL(gre_handle_offloads);
EXPORT_SYMBOL_GPL(rpl_gre_handle_offloads);

static bool is_gre_gso(struct sk_buff *skb)
{
return skb_is_gso(skb);
}

void gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
void rpl_gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
int hdr_len)
{
struct gre_base_hdr *greh;
Expand Down Expand Up @@ -337,7 +337,7 @@ void gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi,

ovs_skb_set_inner_protocol(skb, tpi->proto);
}
EXPORT_SYMBOL_GPL(gre_build_header);
EXPORT_SYMBOL_GPL(rpl_gre_build_header);

#endif /* CONFIG_NET_IPGRE_DEMUX */

Expand Down
3 changes: 3 additions & 0 deletions datapath/linux/compat/gso.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ int rpl_dev_queue_xmit(struct sk_buff *skb)
kfree_skb(skb);
return err;
}
EXPORT_SYMBOL_GPL(rpl_dev_queue_xmit);
#endif /* 3.16 */

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
Expand Down Expand Up @@ -296,4 +297,6 @@ int rpl_ip_local_out(struct sk_buff *skb)
}
return ret;
}
EXPORT_SYMBOL_GPL(rpl_ip_local_out);

#endif /* 3.18 */
2 changes: 1 addition & 1 deletion datapath/linux/compat/gso.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static inline __be16 ovs_skb_get_inner_protocol(struct sk_buff *skb)

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
#define ip_local_out rpl_ip_local_out
int ip_local_out(struct sk_buff *skb);
int rpl_ip_local_out(struct sk_buff *skb);

static inline int skb_inner_mac_offset(const struct sk_buff *skb)
{
Expand Down
Loading

0 comments on commit bedf02f

Please sign in to comment.