]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
ipopt: drop unused 'ptr' argument
authorFlorian Westphal <fw@strlen.de>
Fri, 3 Dec 2021 16:07:53 +0000 (17:07 +0100)
committerFlorian Westphal <fw@strlen.de>
Tue, 7 Dec 2021 11:23:21 +0000 (12:23 +0100)
Its always 0, so remove it.
Looks like this was intended to support variable options that have
array-like members, but so far this isn't implemented, better remove
dead code and implement it properly when such support is needed.

Signed-off-by: Florian Westphal <fw@strlen.de>
include/ipopt.h
src/ipopt.c
src/parser_bison.y
src/parser_json.c

index d8d48066ae50b40c87908523f45eb258f294a771..03420dc6221d48809735f1e26c8b27801713f3de 100644 (file)
@@ -6,7 +6,7 @@
 #include <statement.h>
 
 extern struct expr *ipopt_expr_alloc(const struct location *loc,
-                                     uint8_t type, uint8_t field, uint8_t ptr);
+                                     uint8_t type, uint8_t field);
 
 extern void ipopt_init_raw(struct expr *expr, uint8_t type,
                            unsigned int offset, unsigned int len,
index 5f9f908c0b34ad2fe33834e413e18261f776075b..42ea41cd705b2666a2d12cba5c09940520bdb9ec 100644 (file)
@@ -66,27 +66,8 @@ const struct exthdr_desc *ipopt_protocols[UINT8_MAX] = {
        [IPOPT_RA]              = &ipopt_ra,
 };
 
-static unsigned int calc_offset(const struct exthdr_desc *desc,
-                               const struct proto_hdr_template *tmpl,
-                               unsigned int arg)
-{
-       if (!desc || tmpl == &ipopt_unknown_template)
-               return 0;
-
-       switch (desc->type) {
-       case IPOPT_RR:
-       case IPOPT_LSRR:
-       case IPOPT_SSRR:
-               if (tmpl == &desc->templates[IPOPT_FIELD_ADDR_0])
-                       return (tmpl->offset < 24) ? 0 : arg;
-               return 0;
-       default:
-               return 0;
-       }
-}
-
 struct expr *ipopt_expr_alloc(const struct location *loc, uint8_t type,
-                              uint8_t field, uint8_t ptr)
+                              uint8_t field)
 {
        const struct proto_hdr_template *tmpl;
        const struct exthdr_desc *desc;
@@ -102,7 +83,7 @@ struct expr *ipopt_expr_alloc(const struct location *loc, uint8_t type,
        expr->exthdr.desc   = desc;
        expr->exthdr.tmpl   = tmpl;
        expr->exthdr.op     = NFT_EXTHDR_OP_IPV4;
-       expr->exthdr.offset = tmpl->offset + calc_offset(desc, tmpl, ptr);
+       expr->exthdr.offset = tmpl->offset;
        expr->exthdr.raw_type = desc->type;
 
        return expr;
index 355758e1befb2e25dc9e4fe147ab3d1469557ac4..357850dececc52441fb41c74df31370eb4fa30e9 100644 (file)
@@ -5331,11 +5331,11 @@ ip_hdr_expr             :       IP      ip_hdr_field    close_scope_ip
                        }
                        |       IP      OPTION  ip_option_type ip_option_field  close_scope_ip
                        {
-                               $$ = ipopt_expr_alloc(&@$, $3, $4, 0);
+                               $$ = ipopt_expr_alloc(&@$, $3, $4);
                        }
                        |       IP      OPTION  ip_option_type close_scope_ip
                        {
-                               $$ = ipopt_expr_alloc(&@$, $3, IPOPT_FIELD_TYPE, 0);
+                               $$ = ipopt_expr_alloc(&@$, $3, IPOPT_FIELD_TYPE);
                                $$->exthdr.flags = NFT_EXTHDR_F_PRESENT;
                        }
                        ;
index 7a2d30ff665c552f162a395d884e4e48756e5430..2fad308f7783b3def8bca7f8162b0b2ba08255f4 100644 (file)
@@ -689,7 +689,7 @@ static struct expr *json_parse_ip_option_expr(struct json_ctx *ctx,
 
        if (json_unpack(root, "{s:s}", "field", &field)) {
                expr = ipopt_expr_alloc(int_loc, descval,
-                                        IPOPT_FIELD_TYPE, 0);
+                                        IPOPT_FIELD_TYPE);
                expr->exthdr.flags = NFT_EXTHDR_F_PRESENT;
 
                return expr;
@@ -698,7 +698,7 @@ static struct expr *json_parse_ip_option_expr(struct json_ctx *ctx,
                json_error(ctx, "Unknown ip option field '%s'.", field);
                return NULL;
        }
-       return ipopt_expr_alloc(int_loc, descval, fieldval, 0);
+       return ipopt_expr_alloc(int_loc, descval, fieldval);
 }
 
 static int json_parse_sctp_chunk_field(const struct exthdr_desc *desc,