Make create_object callback optional and return EOPNOTSUPP when it isn't

defined. Remove eaction_create_compat() and use designated initializers to
initialize eaction_opcodes structure.

Obtained from:	Yandex LLC
This commit is contained in:
Andrey V. Elsukov 2016-04-27 15:28:25 +00:00
parent b99bce73e2
commit 9a5be809ab
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298702
2 changed files with 10 additions and 13 deletions

View File

@ -151,20 +151,14 @@ eaction_findbykidx(struct ip_fw_chain *ch, uint16_t idx)
return (ipfw_objhash_lookup_kidx(CHAIN_TO_SRV(ch), idx));
}
static int
eaction_create_compat(struct ip_fw_chain *ch, struct tid_info *ti,
uint16_t *pkidx)
{
return (EOPNOTSUPP);
}
static struct opcode_obj_rewrite eaction_opcodes[] = {
{
O_EXTERNAL_ACTION, IPFW_TLV_EACTION,
eaction_classify, eaction_update,
eaction_findbyname, eaction_findbykidx,
eaction_create_compat
.opcode = O_EXTERNAL_ACTION,
.etlv = IPFW_TLV_EACTION,
.classifier = eaction_classify,
.update = eaction_update,
.find_byname = eaction_findbyname,
.find_bykidx = eaction_findbykidx,
},
};

View File

@ -2236,7 +2236,10 @@ create_objects_compat(struct ip_fw_chain *ch, ipfw_insn *cmd,
KASSERT(rw != NULL, ("Unable to find handler for op %d",
(cmd + p->off)->opcode));
error = rw->create_object(ch, ti, &kidx);
if (rw->create_object == NULL)
error = EOPNOTSUPP;
else
error = rw->create_object(ch, ti, &kidx);
if (error == 0) {
p->kidx = kidx;
continue;