Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df293bbb authored by Yasuyuki Kozakai's avatar Yasuyuki Kozakai Committed by David S. Miller
Browse files

[NETFILTER]: ctnetlink: clear helper area and handle unchanged helper



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: default avatarYasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fda61436
Loading
Loading
Loading
Loading
+22 −18
Original line number Diff line number Diff line
@@ -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;
@@ -843,25 +838,34 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])
	if (err < 0)
		return err;

	if (!strcmp(helpname, "")) {
		if (help && help->helper) {
			/* we had a helper before ... */
			nf_ct_remove_expectations(ct);
			help->helper = NULL;
		}

		return 0;
	}

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

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

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

	if (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));
		}
	}

	help->helper = helper;

	return 0;