Skip to content

Commit

Permalink
[NETFILTER]: ctnetlink: clear helper area and handle unchanged helper
Browse files Browse the repository at this point in the history
This patch
- Clears private area for helper even if no helper is assigned to
  conntrack. It might be used by old helper.
- Unchanges if the same helper as the used one is specified.
- Does not find helper if no helper is specified. And it does not
  require private area for helper in that case.

Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yasuyuki Kozakai authored and David S. Miller committed May 11, 2007
1 parent fda6143 commit df293bb
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions net/netfilter/nf_conntrack_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,11 +830,6 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])
char *helpname;
int err;

if (!help) {
/* FIXME: we need to reallocate and rehash */
return -EBUSY;
}

/* don't change helper of sibling connections */
if (ct->master)
return -EINVAL;
Expand All @@ -843,25 +838,34 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])
if (err < 0)
return err;

helper = __nf_conntrack_helper_find_byname(helpname);
if (!helper) {
if (!strcmp(helpname, ""))
helper = NULL;
else
return -EINVAL;
}

if (help->helper) {
if (!helper) {
if (!strcmp(helpname, "")) {
if (help && help->helper) {
/* we had a helper before ... */
nf_ct_remove_expectations(ct);
help->helper = NULL;
} else {
/* need to zero data of old helper */
memset(&help->help, 0, sizeof(help->help));
}

return 0;
}

if (!help) {
/* FIXME: we need to reallocate and rehash */
return -EBUSY;
}

helper = __nf_conntrack_helper_find_byname(helpname);
if (helper == NULL)
return -EINVAL;

if (help->helper == helper)
return 0;

if (help->helper)
/* we had a helper before ... */
nf_ct_remove_expectations(ct);

/* need to zero data of old helper */
memset(&help->help, 0, sizeof(help->help));
help->helper = helper;

return 0;
Expand Down

0 comments on commit df293bb

Please sign in to comment.