mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-04 12:28:58 +00:00
Allow for IP_FW_ADD to be used in getsockopt(2) incarnation as
well, in which case return the rule number back into userland. PR: bin/18351 Reviewed by: archie, luigi
This commit is contained in:
parent
67467625e2
commit
bc95ac80b2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=67003
@ -2131,11 +2131,11 @@ badviacombo:
|
|||||||
rule.fw_loghighest = rule.fw_logamount;
|
rule.fw_loghighest = rule.fw_logamount;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
i = sizeof(rule);
|
||||||
|
if (getsockopt(s, IPPROTO_IP, IP_FW_ADD, &rule, &i) == -1)
|
||||||
|
err(EX_UNAVAILABLE, "getsockopt(%s)", "IP_FW_ADD");
|
||||||
if (!do_quiet)
|
if (!do_quiet)
|
||||||
show_ipfw(&rule, 10, 10);
|
show_ipfw(&rule, 10, 10);
|
||||||
i = setsockopt(s, IPPROTO_IP, IP_FW_ADD, &rule, sizeof rule);
|
|
||||||
if (i)
|
|
||||||
err(EX_UNAVAILABLE, "setsockopt(%s)", "IP_FW_ADD");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1512,7 +1512,7 @@ add_entry(struct ip_fw_head *chainptr, struct ip_fw *frwl)
|
|||||||
}
|
}
|
||||||
if (nbr < IPFW_DEFAULT_RULE - 100)
|
if (nbr < IPFW_DEFAULT_RULE - 100)
|
||||||
nbr += 100;
|
nbr += 100;
|
||||||
ftmp->fw_number = nbr;
|
ftmp->fw_number = frwl->fw_number = nbr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Got a valid number; now insert it, keeping the list ordered */
|
/* Got a valid number; now insert it, keeping the list ordered */
|
||||||
@ -1928,6 +1928,8 @@ ip_fw_ctl(struct sockopt *sopt)
|
|||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
} else {
|
} else {
|
||||||
error = add_entry(&ip_fw_chain, &frwl);
|
error = add_entry(&ip_fw_chain, &frwl);
|
||||||
|
if (!error && sopt->sopt_dir == SOPT_GET)
|
||||||
|
error = sooptcopyout(sopt, &frwl, sizeof frwl);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -259,6 +259,7 @@ rip_ctloutput(so, sopt)
|
|||||||
error = sooptcopyout(sopt, &optval, sizeof optval);
|
error = sooptcopyout(sopt, &optval, sizeof optval);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IP_FW_ADD:
|
||||||
case IP_FW_GET:
|
case IP_FW_GET:
|
||||||
if (ip_fw_ctl_ptr == 0)
|
if (ip_fw_ctl_ptr == 0)
|
||||||
error = ENOPROTOOPT;
|
error = ENOPROTOOPT;
|
||||||
|
Loading…
Reference in New Issue
Block a user