Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: Remove state argument from skb_find_text()

Although it is clear that textsearch state is intentionally passed to
skb_find_text() as uninitialized argument, it was never used by the
callers. Therefore, we can simplify skb_find_text() by making it
local variable.

Signed-off-by: Bojan Prtvar <prtvar.b@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Bojan Prtvar and committed by
David S. Miller
059a2440 d340c862

+10 -18
+1 -2
include/linux/skbuff.h
··· 870 870 void skb_abort_seq_read(struct skb_seq_state *st); 871 871 872 872 unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, 873 - unsigned int to, struct ts_config *config, 874 - struct ts_state *state); 873 + unsigned int to, struct ts_config *config); 875 874 876 875 /* 877 876 * Packet hash types specify the type of hash in skb_set_hash.
+4 -5
net/core/skbuff.c
··· 2865 2865 * @from: search offset 2866 2866 * @to: search limit 2867 2867 * @config: textsearch configuration 2868 - * @state: uninitialized textsearch state variable 2869 2868 * 2870 2869 * Finds a pattern in the skb data according to the specified 2871 2870 * textsearch configuration. Use textsearch_next() to retrieve ··· 2872 2873 * to the first occurrence or UINT_MAX if no match was found. 2873 2874 */ 2874 2875 unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, 2875 - unsigned int to, struct ts_config *config, 2876 - struct ts_state *state) 2876 + unsigned int to, struct ts_config *config) 2877 2877 { 2878 + struct ts_state state; 2878 2879 unsigned int ret; 2879 2880 2880 2881 config->get_next_block = skb_ts_get_next_block; 2881 2882 config->finish = skb_ts_finish; 2882 2883 2883 - skb_prepare_seq_read(skb, from, to, TS_SKB_CB(state)); 2884 + skb_prepare_seq_read(skb, from, to, TS_SKB_CB(&state)); 2884 2885 2885 - ret = textsearch_find(config, state); 2886 + ret = textsearch_find(config, &state); 2886 2887 return (ret <= to - from ? ret : UINT_MAX); 2887 2888 } 2888 2889 EXPORT_SYMBOL(skb_find_text);
+3 -7
net/netfilter/nf_conntrack_amanda.c
··· 88 88 struct nf_conn *ct, 89 89 enum ip_conntrack_info ctinfo) 90 90 { 91 - struct ts_state ts; 92 91 struct nf_conntrack_expect *exp; 93 92 struct nf_conntrack_tuple *tuple; 94 93 unsigned int dataoff, start, stop, off, i; ··· 112 113 return NF_ACCEPT; 113 114 } 114 115 115 - memset(&ts, 0, sizeof(ts)); 116 116 start = skb_find_text(skb, dataoff, skb->len, 117 - search[SEARCH_CONNECT].ts, &ts); 117 + search[SEARCH_CONNECT].ts); 118 118 if (start == UINT_MAX) 119 119 goto out; 120 120 start += dataoff + search[SEARCH_CONNECT].len; 121 121 122 - memset(&ts, 0, sizeof(ts)); 123 122 stop = skb_find_text(skb, start, skb->len, 124 - search[SEARCH_NEWLINE].ts, &ts); 123 + search[SEARCH_NEWLINE].ts); 125 124 if (stop == UINT_MAX) 126 125 goto out; 127 126 stop += start; 128 127 129 128 for (i = SEARCH_DATA; i <= SEARCH_INDEX; i++) { 130 - memset(&ts, 0, sizeof(ts)); 131 - off = skb_find_text(skb, start, stop, search[i].ts, &ts); 129 + off = skb_find_text(skb, start, stop, search[i].ts); 132 130 if (off == UINT_MAX) 133 131 continue; 134 132 off += start + search[i].len;
+1 -2
net/netfilter/xt_string.c
··· 26 26 string_mt(const struct sk_buff *skb, struct xt_action_param *par) 27 27 { 28 28 const struct xt_string_info *conf = par->matchinfo; 29 - struct ts_state state; 30 29 bool invert; 31 30 32 31 invert = conf->u.v1.flags & XT_STRING_FLAG_INVERT; 33 32 34 33 return (skb_find_text((struct sk_buff *)skb, conf->from_offset, 35 - conf->to_offset, conf->config, &state) 34 + conf->to_offset, conf->config) 36 35 != UINT_MAX) ^ invert; 37 36 } 38 37
+1 -2
net/sched/em_text.c
··· 34 34 { 35 35 struct text_match *tm = EM_TEXT_PRIV(m); 36 36 int from, to; 37 - struct ts_state state; 38 37 39 38 from = tcf_get_base_ptr(skb, tm->from_layer) - skb->data; 40 39 from += tm->from_offset; ··· 41 42 to = tcf_get_base_ptr(skb, tm->to_layer) - skb->data; 42 43 to += tm->to_offset; 43 44 44 - return skb_find_text(skb, from, to, tm->config, &state) != UINT_MAX; 45 + return skb_find_text(skb, from, to, tm->config) != UINT_MAX; 45 46 } 46 47 47 48 static int em_text_change(struct net *net, void *data, int len,