From 9a5be809ab04eefc22fe288a279e350eadfab176 Mon Sep 17 00:00:00 2001 From: "Andrey V. Elsukov" Date: Wed, 27 Apr 2016 15:28:25 +0000 Subject: [PATCH] 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 --- sys/netpfil/ipfw/ip_fw_eaction.c | 18 ++++++------------ sys/netpfil/ipfw/ip_fw_sockopt.c | 5 ++++- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/sys/netpfil/ipfw/ip_fw_eaction.c b/sys/netpfil/ipfw/ip_fw_eaction.c index 144bf49db381..09e0310b7dbc 100644 --- a/sys/netpfil/ipfw/ip_fw_eaction.c +++ b/sys/netpfil/ipfw/ip_fw_eaction.c @@ -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, }, }; diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c index c63a3036fc5f..5eecf97fcea0 100644 --- a/sys/netpfil/ipfw/ip_fw_sockopt.c +++ b/sys/netpfil/ipfw/ip_fw_sockopt.c @@ -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;