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>
This commit is contained in:
parent
d340c862e7
commit
059a2440fd
5 changed files with 10 additions and 18 deletions
|
@ -870,8 +870,7 @@ unsigned int skb_seq_read(unsigned int consumed, const u8 **data,
|
||||||
void skb_abort_seq_read(struct skb_seq_state *st);
|
void skb_abort_seq_read(struct skb_seq_state *st);
|
||||||
|
|
||||||
unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
|
unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
|
||||||
unsigned int to, struct ts_config *config,
|
unsigned int to, struct ts_config *config);
|
||||||
struct ts_state *state);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Packet hash types specify the type of hash in skb_set_hash.
|
* Packet hash types specify the type of hash in skb_set_hash.
|
||||||
|
|
|
@ -2865,7 +2865,6 @@ static void skb_ts_finish(struct ts_config *conf, struct ts_state *state)
|
||||||
* @from: search offset
|
* @from: search offset
|
||||||
* @to: search limit
|
* @to: search limit
|
||||||
* @config: textsearch configuration
|
* @config: textsearch configuration
|
||||||
* @state: uninitialized textsearch state variable
|
|
||||||
*
|
*
|
||||||
* Finds a pattern in the skb data according to the specified
|
* Finds a pattern in the skb data according to the specified
|
||||||
* textsearch configuration. Use textsearch_next() to retrieve
|
* textsearch configuration. Use textsearch_next() to retrieve
|
||||||
|
@ -2873,17 +2872,17 @@ static void skb_ts_finish(struct ts_config *conf, struct ts_state *state)
|
||||||
* to the first occurrence or UINT_MAX if no match was found.
|
* to the first occurrence or UINT_MAX if no match was found.
|
||||||
*/
|
*/
|
||||||
unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
|
unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
|
||||||
unsigned int to, struct ts_config *config,
|
unsigned int to, struct ts_config *config)
|
||||||
struct ts_state *state)
|
|
||||||
{
|
{
|
||||||
|
struct ts_state state;
|
||||||
unsigned int ret;
|
unsigned int ret;
|
||||||
|
|
||||||
config->get_next_block = skb_ts_get_next_block;
|
config->get_next_block = skb_ts_get_next_block;
|
||||||
config->finish = skb_ts_finish;
|
config->finish = skb_ts_finish;
|
||||||
|
|
||||||
skb_prepare_seq_read(skb, from, to, TS_SKB_CB(state));
|
skb_prepare_seq_read(skb, from, to, TS_SKB_CB(&state));
|
||||||
|
|
||||||
ret = textsearch_find(config, state);
|
ret = textsearch_find(config, &state);
|
||||||
return (ret <= to - from ? ret : UINT_MAX);
|
return (ret <= to - from ? ret : UINT_MAX);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(skb_find_text);
|
EXPORT_SYMBOL(skb_find_text);
|
||||||
|
|
|
@ -88,7 +88,6 @@ static int amanda_help(struct sk_buff *skb,
|
||||||
struct nf_conn *ct,
|
struct nf_conn *ct,
|
||||||
enum ip_conntrack_info ctinfo)
|
enum ip_conntrack_info ctinfo)
|
||||||
{
|
{
|
||||||
struct ts_state ts;
|
|
||||||
struct nf_conntrack_expect *exp;
|
struct nf_conntrack_expect *exp;
|
||||||
struct nf_conntrack_tuple *tuple;
|
struct nf_conntrack_tuple *tuple;
|
||||||
unsigned int dataoff, start, stop, off, i;
|
unsigned int dataoff, start, stop, off, i;
|
||||||
|
@ -113,23 +112,20 @@ static int amanda_help(struct sk_buff *skb,
|
||||||
return NF_ACCEPT;
|
return NF_ACCEPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&ts, 0, sizeof(ts));
|
|
||||||
start = skb_find_text(skb, dataoff, skb->len,
|
start = skb_find_text(skb, dataoff, skb->len,
|
||||||
search[SEARCH_CONNECT].ts, &ts);
|
search[SEARCH_CONNECT].ts);
|
||||||
if (start == UINT_MAX)
|
if (start == UINT_MAX)
|
||||||
goto out;
|
goto out;
|
||||||
start += dataoff + search[SEARCH_CONNECT].len;
|
start += dataoff + search[SEARCH_CONNECT].len;
|
||||||
|
|
||||||
memset(&ts, 0, sizeof(ts));
|
|
||||||
stop = skb_find_text(skb, start, skb->len,
|
stop = skb_find_text(skb, start, skb->len,
|
||||||
search[SEARCH_NEWLINE].ts, &ts);
|
search[SEARCH_NEWLINE].ts);
|
||||||
if (stop == UINT_MAX)
|
if (stop == UINT_MAX)
|
||||||
goto out;
|
goto out;
|
||||||
stop += start;
|
stop += start;
|
||||||
|
|
||||||
for (i = SEARCH_DATA; i <= SEARCH_INDEX; i++) {
|
for (i = SEARCH_DATA; i <= SEARCH_INDEX; i++) {
|
||||||
memset(&ts, 0, sizeof(ts));
|
off = skb_find_text(skb, start, stop, search[i].ts);
|
||||||
off = skb_find_text(skb, start, stop, search[i].ts, &ts);
|
|
||||||
if (off == UINT_MAX)
|
if (off == UINT_MAX)
|
||||||
continue;
|
continue;
|
||||||
off += start + search[i].len;
|
off += start + search[i].len;
|
||||||
|
|
|
@ -26,13 +26,12 @@ static bool
|
||||||
string_mt(const struct sk_buff *skb, struct xt_action_param *par)
|
string_mt(const struct sk_buff *skb, struct xt_action_param *par)
|
||||||
{
|
{
|
||||||
const struct xt_string_info *conf = par->matchinfo;
|
const struct xt_string_info *conf = par->matchinfo;
|
||||||
struct ts_state state;
|
|
||||||
bool invert;
|
bool invert;
|
||||||
|
|
||||||
invert = conf->u.v1.flags & XT_STRING_FLAG_INVERT;
|
invert = conf->u.v1.flags & XT_STRING_FLAG_INVERT;
|
||||||
|
|
||||||
return (skb_find_text((struct sk_buff *)skb, conf->from_offset,
|
return (skb_find_text((struct sk_buff *)skb, conf->from_offset,
|
||||||
conf->to_offset, conf->config, &state)
|
conf->to_offset, conf->config)
|
||||||
!= UINT_MAX) ^ invert;
|
!= UINT_MAX) ^ invert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ static int em_text_match(struct sk_buff *skb, struct tcf_ematch *m,
|
||||||
{
|
{
|
||||||
struct text_match *tm = EM_TEXT_PRIV(m);
|
struct text_match *tm = EM_TEXT_PRIV(m);
|
||||||
int from, to;
|
int from, to;
|
||||||
struct ts_state state;
|
|
||||||
|
|
||||||
from = tcf_get_base_ptr(skb, tm->from_layer) - skb->data;
|
from = tcf_get_base_ptr(skb, tm->from_layer) - skb->data;
|
||||||
from += tm->from_offset;
|
from += tm->from_offset;
|
||||||
|
@ -42,7 +41,7 @@ static int em_text_match(struct sk_buff *skb, struct tcf_ematch *m,
|
||||||
to = tcf_get_base_ptr(skb, tm->to_layer) - skb->data;
|
to = tcf_get_base_ptr(skb, tm->to_layer) - skb->data;
|
||||||
to += tm->to_offset;
|
to += tm->to_offset;
|
||||||
|
|
||||||
return skb_find_text(skb, from, to, tm->config, &state) != UINT_MAX;
|
return skb_find_text(skb, from, to, tm->config) != UINT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int em_text_change(struct net *net, void *data, int len,
|
static int em_text_change(struct net *net, void *data, int len,
|
||||||
|
|
Loading…
Add table
Reference in a new issue