netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Linmujia <linmujia@huawei.com>
Cc: "netfilter-devel@vger.kernel.org" <netfilter-devel@vger.kernel.org>
Subject: Re: [nft patch]add default branch for code integrality
Date: Thu, 26 Nov 2015 10:49:17 +0100	[thread overview]
Message-ID: <20151126094917.GA1578@salvia> (raw)
In-Reply-To: <0A900C78B9F2324AB7F4F7A51D1A2F85779782D0@szxema505-mbs.china.huawei.com>

On Thu, Nov 26, 2015 at 09:32:02AM +0000, Linmujia wrote:
> Hi,I reviewed nftables code and add some default branch for code itegrality.
> 
> Thanks!
> 
> Signed-off-by: linmujia <linmujia@huawei.com>
> ---
> src/netlink.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
> 
> diff --git a/src/netlink.c b/src/netlink.c
> index 974afb1..7821169 100644
> --- a/src/netlink.c
> +++ b/src/netlink.c
> @@ -307,6 +307,8 @@ static void netlink_gen_verdict(const struct expr *expr,
>                 strncpy(data->chain, expr->chain, NFT_CHAIN_MAXNAMELEN);
>                 data->chain[NFT_CHAIN_MAXNAMELEN-1] = '\0';
>                 break;
> +       default:
> +                BUG("invalid verdict value %u\n", expr->verdict);
>        }
> }
> @@ -1670,6 +1672,8 @@ static uint32_t netlink_msg2nftnl_of(uint32_t msg)
>        case NFT_MSG_DELSETELEM:
>        case NFT_MSG_DELRULE:
>                 return NFTNL_OF_EVENT_DEL;
> +       default:
> +                BUG("invalid nft msg type %u\n", msg);
>        }
>         return 0;
> @@ -1741,6 +1745,8 @@ static int netlink_events_table_cb(const struct nlmsghdr *nlh, int type,
>                                      netlink_msg2nftnl_of(type));
>                 fprintf(stdout, "\n");
>                 break;
> +       default:
> +                BUG("invalid output format %u\n", monh->format);

This will break old nft versions with new kernels, in case we add new
netlink messages.

And that is very likely to happen.

           reply	other threads:[~2015-11-26  9:49 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <0A900C78B9F2324AB7F4F7A51D1A2F85779782D0@szxema505-mbs.china.huawei.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151126094917.GA1578@salvia \
    --to=pablo@netfilter.org \
    --cc=linmujia@huawei.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).