diff mbox series

[v3,net-next,1/8] flow_dissector: Change skbuf argument to be non const

Message ID 20170928214823.2426-1-tom@quantonium.net
State Superseded, archived
Delegated to: David Miller
Headers show
Series flow_dissector: Protocol specific flow dissector offload | expand

Commit Message

Tom Herbert Sept. 28, 2017, 9:48 p.m. UTC
Change the skbuf argument of __skb_flow_dissect to be non constant so
that the function can call functions that take non constant skbuf
arguments. This is needed if we are to call socket lookup or BPF in the
flow dissector path.

The changes include unraveling the call chain into __skb_flow_dissect so
that those also use non constant skbufs.

Signed-off-by: Tom Herbert <tom@quantonium.net>
---
 include/linux/skbuff.h    | 12 ++++++------
 include/net/ip_fib.h      |  4 ++--
 include/net/route.h       |  4 ++--
 net/core/flow_dissector.c | 10 +++++-----
 net/ipv4/fib_semantics.c  |  2 +-
 net/ipv4/route.c          |  6 +++---
 net/sched/sch_sfq.c       |  2 +-
 7 files changed, 20 insertions(+), 20 deletions(-)

Comments

kernel test robot Sept. 30, 2017, 9:46 p.m. UTC | #1
Hi Tom,

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Tom-Herbert/flow_dissector-Change-skbuf-argument-to-be-non-const/20171001-052131
config: x86_64-randconfig-x010-201740 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/sfc/rx.c: In function 'efx_filter_rfs':
>> drivers/net/ethernet/sfc/rx.c:842:34: warning: passing argument 1 of 'skb_flow_dissect_flow_keys' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     if (!skb_flow_dissect_flow_keys(skb, &fk, 0))
                                     ^~~
   In file included from include/linux/ip.h:20:0,
                    from drivers/net/ethernet/sfc/rx.c:14:
   include/linux/skbuff.h:1189:20: note: expected 'struct sk_buff *' but argument is of type 'const struct sk_buff *'
    static inline bool skb_flow_dissect_flow_keys(struct sk_buff *skb,
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
--
   drivers/net/ethernet/sfc/falcon/rx.c: In function 'ef4_filter_rfs':
>> drivers/net/ethernet/sfc/falcon/rx.c:848:34: warning: passing argument 1 of 'skb_flow_dissect_flow_keys' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     if (!skb_flow_dissect_flow_keys(skb, &fk, 0))
                                     ^~~
   In file included from include/linux/ip.h:20:0,
                    from drivers/net/ethernet/sfc/falcon/rx.c:14:
   include/linux/skbuff.h:1189:20: note: expected 'struct sk_buff *' but argument is of type 'const struct sk_buff *'
    static inline bool skb_flow_dissect_flow_keys(struct sk_buff *skb,
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~

vim +842 drivers/net/ethernet/sfc/rx.c

add724771 Ben Hutchings 2012-11-08  829  
add724771 Ben Hutchings 2012-11-08  830  int efx_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
add724771 Ben Hutchings 2012-11-08  831  		   u16 rxq_index, u32 flow_id)
add724771 Ben Hutchings 2012-11-08  832  {
add724771 Ben Hutchings 2012-11-08  833  	struct efx_nic *efx = netdev_priv(net_dev);
add724771 Ben Hutchings 2012-11-08  834  	struct efx_channel *channel;
add724771 Ben Hutchings 2012-11-08  835  	struct efx_filter_spec spec;
68bb399e6 Edward Cree   2016-05-26  836  	struct flow_keys fk;
add724771 Ben Hutchings 2012-11-08  837  	int rc;
add724771 Ben Hutchings 2012-11-08  838  
faf8dcc12 Jon Cooper    2016-05-31  839  	if (flow_id == RPS_FLOW_ID_INVALID)
faf8dcc12 Jon Cooper    2016-05-31  840  		return -EINVAL;
faf8dcc12 Jon Cooper    2016-05-31  841  
68bb399e6 Edward Cree   2016-05-26 @842  	if (!skb_flow_dissect_flow_keys(skb, &fk, 0))
68bb399e6 Edward Cree   2016-05-26  843  		return -EPROTONOSUPPORT;
add724771 Ben Hutchings 2012-11-08  844  
68bb399e6 Edward Cree   2016-05-26  845  	if (fk.basic.n_proto != htons(ETH_P_IP) && fk.basic.n_proto != htons(ETH_P_IPV6))
68bb399e6 Edward Cree   2016-05-26  846  		return -EPROTONOSUPPORT;
68bb399e6 Edward Cree   2016-05-26  847  	if (fk.control.flags & FLOW_DIS_IS_FRAGMENT)
c47b2d9d5 Ben Hutchings 2013-09-03  848  		return -EPROTONOSUPPORT;
c47b2d9d5 Ben Hutchings 2013-09-03  849  
c47b2d9d5 Ben Hutchings 2013-09-03  850  	efx_filter_init_rx(&spec, EFX_FILTER_PRI_HINT,
c47b2d9d5 Ben Hutchings 2013-09-03  851  			   efx->rx_scatter ? EFX_FILTER_FLAG_RX_SCATTER : 0,
c47b2d9d5 Ben Hutchings 2013-09-03  852  			   rxq_index);
c47b2d9d5 Ben Hutchings 2013-09-03  853  	spec.match_flags =
c47b2d9d5 Ben Hutchings 2013-09-03  854  		EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_IP_PROTO |
c47b2d9d5 Ben Hutchings 2013-09-03  855  		EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_LOC_PORT |
c47b2d9d5 Ben Hutchings 2013-09-03  856  		EFX_FILTER_MATCH_REM_HOST | EFX_FILTER_MATCH_REM_PORT;
68bb399e6 Edward Cree   2016-05-26  857  	spec.ether_type = fk.basic.n_proto;
68bb399e6 Edward Cree   2016-05-26  858  	spec.ip_proto = fk.basic.ip_proto;
c47b2d9d5 Ben Hutchings 2013-09-03  859  
68bb399e6 Edward Cree   2016-05-26  860  	if (fk.basic.n_proto == htons(ETH_P_IP)) {
68bb399e6 Edward Cree   2016-05-26  861  		spec.rem_host[0] = fk.addrs.v4addrs.src;
68bb399e6 Edward Cree   2016-05-26  862  		spec.loc_host[0] = fk.addrs.v4addrs.dst;
c47b2d9d5 Ben Hutchings 2013-09-03  863  	} else {
68bb399e6 Edward Cree   2016-05-26  864  		memcpy(spec.rem_host, &fk.addrs.v6addrs.src, sizeof(struct in6_addr));
68bb399e6 Edward Cree   2016-05-26  865  		memcpy(spec.loc_host, &fk.addrs.v6addrs.dst, sizeof(struct in6_addr));
c47b2d9d5 Ben Hutchings 2013-09-03  866  	}
c47b2d9d5 Ben Hutchings 2013-09-03  867  
68bb399e6 Edward Cree   2016-05-26  868  	spec.rem_port = fk.ports.src;
68bb399e6 Edward Cree   2016-05-26  869  	spec.loc_port = fk.ports.dst;
add724771 Ben Hutchings 2012-11-08  870  
add724771 Ben Hutchings 2012-11-08  871  	rc = efx->type->filter_rfs_insert(efx, &spec);
add724771 Ben Hutchings 2012-11-08  872  	if (rc < 0)
add724771 Ben Hutchings 2012-11-08  873  		return rc;
add724771 Ben Hutchings 2012-11-08  874  
add724771 Ben Hutchings 2012-11-08  875  	/* Remember this so we can check whether to expire the filter later */
faf8dcc12 Jon Cooper    2016-05-31  876  	channel = efx_get_channel(efx, rxq_index);
faf8dcc12 Jon Cooper    2016-05-31  877  	channel->rps_flow_id[rc] = flow_id;
add724771 Ben Hutchings 2012-11-08  878  	++channel->rfs_filters_added;
add724771 Ben Hutchings 2012-11-08  879  
68bb399e6 Edward Cree   2016-05-26  880  	if (spec.ether_type == htons(ETH_P_IP))
add724771 Ben Hutchings 2012-11-08  881  		netif_info(efx, rx_status, efx->net_dev,
add724771 Ben Hutchings 2012-11-08  882  			   "steering %s %pI4:%u:%pI4:%u to queue %u [flow %u filter %d]\n",
c47b2d9d5 Ben Hutchings 2013-09-03  883  			   (spec.ip_proto == IPPROTO_TCP) ? "TCP" : "UDP",
68bb399e6 Edward Cree   2016-05-26  884  			   spec.rem_host, ntohs(spec.rem_port), spec.loc_host,
68bb399e6 Edward Cree   2016-05-26  885  			   ntohs(spec.loc_port), rxq_index, flow_id, rc);
c47b2d9d5 Ben Hutchings 2013-09-03  886  	else
c47b2d9d5 Ben Hutchings 2013-09-03  887  		netif_info(efx, rx_status, efx->net_dev,
c47b2d9d5 Ben Hutchings 2013-09-03  888  			   "steering %s [%pI6]:%u:[%pI6]:%u to queue %u [flow %u filter %d]\n",
c47b2d9d5 Ben Hutchings 2013-09-03  889  			   (spec.ip_proto == IPPROTO_TCP) ? "TCP" : "UDP",
68bb399e6 Edward Cree   2016-05-26  890  			   spec.rem_host, ntohs(spec.rem_port), spec.loc_host,
68bb399e6 Edward Cree   2016-05-26  891  			   ntohs(spec.loc_port), rxq_index, flow_id, rc);
add724771 Ben Hutchings 2012-11-08  892  
add724771 Ben Hutchings 2012-11-08  893  	return rc;
add724771 Ben Hutchings 2012-11-08  894  }
add724771 Ben Hutchings 2012-11-08  895  

:::::: The code at line 842 was first introduced by commit
:::::: 68bb399e656f244d3d173a20a8280c167632fca8 sfc: use flow dissector helpers for aRFS

:::::: TO: Edward Cree <ecree@solarflare.com>
:::::: CC: David S. Miller <davem@davemloft.net>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 19e64bfb1a66..5a6e765e120f 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1155,8 +1155,8 @@  __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4)
 }
 
 void __skb_get_hash(struct sk_buff *skb);
-u32 __skb_get_hash_symmetric(const struct sk_buff *skb);
-u32 skb_get_poff(const struct sk_buff *skb);
+u32 __skb_get_hash_symmetric(struct sk_buff *skb);
+u32 skb_get_poff(struct sk_buff *skb);
 u32 __skb_get_poff(const struct sk_buff *skb, void *data,
 		   const struct flow_keys *keys, int hlen);
 __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
@@ -1172,13 +1172,13 @@  void skb_flow_dissector_init(struct flow_dissector *flow_dissector,
 			     const struct flow_dissector_key *key,
 			     unsigned int key_count);
 
-bool __skb_flow_dissect(const struct sk_buff *skb,
+bool __skb_flow_dissect(struct sk_buff *skb,
 			struct flow_dissector *flow_dissector,
 			void *target_container,
 			void *data, __be16 proto, int nhoff, int hlen,
 			unsigned int flags);
 
-static inline bool skb_flow_dissect(const struct sk_buff *skb,
+static inline bool skb_flow_dissect(struct sk_buff *skb,
 				    struct flow_dissector *flow_dissector,
 				    void *target_container, unsigned int flags)
 {
@@ -1186,7 +1186,7 @@  static inline bool skb_flow_dissect(const struct sk_buff *skb,
 				  NULL, 0, 0, 0, flags);
 }
 
-static inline bool skb_flow_dissect_flow_keys(const struct sk_buff *skb,
+static inline bool skb_flow_dissect_flow_keys(struct sk_buff *skb,
 					      struct flow_keys *flow,
 					      unsigned int flags)
 {
@@ -1225,7 +1225,7 @@  static inline __u32 skb_get_hash_flowi6(struct sk_buff *skb, const struct flowi6
 	return skb->hash;
 }
 
-__u32 skb_get_hash_perturb(const struct sk_buff *skb, u32 perturb);
+__u32 skb_get_hash_perturb(struct sk_buff *skb, u32 perturb);
 
 static inline __u32 skb_get_hash_raw(const struct sk_buff *skb)
 {
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 1a7f7e424320..a376dfe1ad44 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -374,11 +374,11 @@  int fib_sync_up(struct net_device *dev, unsigned int nh_flags);
 
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 int fib_multipath_hash(const struct fib_info *fi, const struct flowi4 *fl4,
-		       const struct sk_buff *skb);
+		       struct sk_buff *skb);
 #endif
 void fib_select_multipath(struct fib_result *res, int hash);
 void fib_select_path(struct net *net, struct fib_result *res,
-		     struct flowi4 *fl4, const struct sk_buff *skb);
+		     struct flowi4 *fl4, struct sk_buff *skb);
 
 /* Exported by fib_trie.c */
 void fib_trie_init(void);
diff --git a/include/net/route.h b/include/net/route.h
index 57dfc6850d37..cb95b79f0117 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -114,10 +114,10 @@  int ip_rt_init(void);
 void rt_cache_flush(struct net *net);
 void rt_flush_dev(struct net_device *dev);
 struct rtable *ip_route_output_key_hash(struct net *net, struct flowi4 *flp,
-					const struct sk_buff *skb);
+					struct sk_buff *skb);
 struct rtable *ip_route_output_key_hash_rcu(struct net *net, struct flowi4 *flp,
 					    struct fib_result *res,
-					    const struct sk_buff *skb);
+					    struct sk_buff *skb);
 
 static inline struct rtable *__ip_route_output_key(struct net *net,
 						   struct flowi4 *flp)
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 0a977373d003..76f5e5bc3177 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -424,7 +424,7 @@  static bool skb_flow_dissect_allowed(int *num_hdrs)
  *
  * Caller must take care of zeroing target container memory.
  */
-bool __skb_flow_dissect(const struct sk_buff *skb,
+bool __skb_flow_dissect(struct sk_buff *skb,
 			struct flow_dissector *flow_dissector,
 			void *target_container,
 			void *data, __be16 proto, int nhoff, int hlen,
@@ -1015,7 +1015,7 @@  u32 flow_hash_from_keys(struct flow_keys *keys)
 }
 EXPORT_SYMBOL(flow_hash_from_keys);
 
-static inline u32 ___skb_get_hash(const struct sk_buff *skb,
+static inline u32 ___skb_get_hash(struct sk_buff *skb,
 				  struct flow_keys *keys, u32 keyval)
 {
 	skb_flow_dissect_flow_keys(skb, keys,
@@ -1053,7 +1053,7 @@  EXPORT_SYMBOL(make_flow_keys_digest);
 
 static struct flow_dissector flow_keys_dissector_symmetric __read_mostly;
 
-u32 __skb_get_hash_symmetric(const struct sk_buff *skb)
+u32 __skb_get_hash_symmetric(struct sk_buff *skb)
 {
 	struct flow_keys keys;
 
@@ -1090,7 +1090,7 @@  void __skb_get_hash(struct sk_buff *skb)
 }
 EXPORT_SYMBOL(__skb_get_hash);
 
-__u32 skb_get_hash_perturb(const struct sk_buff *skb, u32 perturb)
+__u32 skb_get_hash_perturb(struct sk_buff *skb, u32 perturb)
 {
 	struct flow_keys keys;
 
@@ -1158,7 +1158,7 @@  u32 __skb_get_poff(const struct sk_buff *skb, void *data,
  * truncate packets without needing to push actual payload to the user
  * space and can analyze headers only, instead.
  */
-u32 skb_get_poff(const struct sk_buff *skb)
+u32 skb_get_poff(struct sk_buff *skb)
 {
 	struct flow_keys keys;
 
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 57a5d48acee8..dc610646bc4c 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1759,7 +1759,7 @@  void fib_select_multipath(struct fib_result *res, int hash)
 #endif
 
 void fib_select_path(struct net *net, struct fib_result *res,
-		     struct flowi4 *fl4, const struct sk_buff *skb)
+		     struct flowi4 *fl4, struct sk_buff *skb)
 {
 	bool oif_check;
 
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 94d4cd2d5ea4..94c5b81d8f2b 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1791,7 +1791,7 @@  static void ip_multipath_l3_keys(const struct sk_buff *skb,
 
 /* if skb is set it will be used and fl4 can be NULL */
 int fib_multipath_hash(const struct fib_info *fi, const struct flowi4 *fl4,
-		       const struct sk_buff *skb)
+		       struct sk_buff *skb)
 {
 	struct net *net = fi->fib_net;
 	struct flow_keys hash_keys;
@@ -2270,7 +2270,7 @@  static struct rtable *__mkroute_output(const struct fib_result *res,
  */
 
 struct rtable *ip_route_output_key_hash(struct net *net, struct flowi4 *fl4,
-					const struct sk_buff *skb)
+					struct sk_buff *skb)
 {
 	__u8 tos = RT_FL_TOS(fl4);
 	struct fib_result res;
@@ -2295,7 +2295,7 @@  EXPORT_SYMBOL_GPL(ip_route_output_key_hash);
 
 struct rtable *ip_route_output_key_hash_rcu(struct net *net, struct flowi4 *fl4,
 					    struct fib_result *res,
-					    const struct sk_buff *skb)
+					    struct sk_buff *skb)
 {
 	struct net_device *dev_out = NULL;
 	int orig_oif = fl4->flowi4_oif;
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index 74ea863b8240..0d2d3a8d03f0 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -158,7 +158,7 @@  static inline struct sfq_head *sfq_dep_head(struct sfq_sched_data *q, sfq_index
 }
 
 static unsigned int sfq_hash(const struct sfq_sched_data *q,
-			     const struct sk_buff *skb)
+			     struct sk_buff *skb)
 {
 	return skb_get_hash_perturb(skb, q->perturbation) & (q->divisor - 1);
 }