From: Hangbin Liu <liuhangbin@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Jay Vosburgh <j.vosburgh@gmail.com>,
Veaceslav Falico <vfalico@gmail.com>,
Andy Gospodarek <andy@greyhouse.net>,
"David S . Miller" <davem@davemloft.net>,
Richard Cochran <richardcochran@gmail.com>,
Heiner Kallweit <hkallweit1@gmail.com>
Subject: Re: [PATCH net-next 1/2] net_tstamp: add new flag HWTSTAMP_FLAGS_UNSTABLE_PHC
Date: Wed, 8 Dec 2021 14:27:49 +0800 [thread overview]
Message-ID: <YbBQZUoQjDC6Ea23@Laptop-X1> (raw)
In-Reply-To: <20211207220814.0ca3403f@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
On Tue, Dec 07, 2021 at 10:08:14PM -0800, Jakub Kicinski wrote:
> On Wed, 8 Dec 2021 12:42:23 +0800 Hangbin Liu wrote:
> > - /* Reserved for future extensions */
> > - if (config->flags)
> > - return -EINVAL;
>
> Should we do something like:
>
> if (config->flags & ~PHC_DRIVER_IGNORED_FLAGS)
> return -EINVAL;
>
> Or whatnot? We still want the drivers to reject bits other than the new
> flag.
How about just add the check in net_hwtstamp_validate().
I think that should be enough. e.g.
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index a81c98cfc3db..256d2e26487f 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -186,15 +186,27 @@ static int net_hwtstamp_validate(struct ifreq *ifr)
struct hwtstamp_config cfg;
enum hwtstamp_tx_types tx_type;
enum hwtstamp_rx_filters rx_filter;
- int tx_type_valid = 0;
+ enum hwtstamp_flags flags;
int rx_filter_valid = 0;
+ int tx_type_valid = 0;
+ int flags_valid = 0;
if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
return -EFAULT;
+ flags = cfg.flags;
tx_type = cfg.tx_type;
rx_filter = cfg.rx_filter;
+ switch (flags) {
+ case HWTSTAMP_FLAGS_UNSTABLE_PHC:
+ flags_valid = 1;
+ break;
+ case __HWTSTAMP_FLAGS_CNT:
+ /* not a real value */
+ break;
+ }
+
switch (tx_type) {
case HWTSTAMP_TX_OFF:
case HWTSTAMP_TX_ON:
@@ -231,7 +243,7 @@ static int net_hwtstamp_validate(struct ifreq *ifr)
break;
}
- if (!tx_type_valid || !rx_filter_valid)
+ if (!flags_valid || !tx_type_valid || !rx_filter_valid)
return -ERANGE;
return 0;
next prev parent reply other threads:[~2021-12-08 6:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-08 4:42 [PATCH net-next 0/2] net: add new hwtstamp flag HWTSTAMP_FLAGS_UNSTABLE_PHC Hangbin Liu
2021-12-08 4:42 ` [PATCH net-next 1/2] net_tstamp: add new " Hangbin Liu
2021-12-08 6:08 ` Jakub Kicinski
2021-12-08 6:27 ` Hangbin Liu [this message]
2021-12-08 22:03 ` Jakub Kicinski
2021-12-08 15:20 ` Richard Cochran
2021-12-09 4:31 ` Hangbin Liu
2021-12-09 21:22 ` Richard Cochran
2021-12-09 21:30 ` Richard Cochran
2021-12-08 4:42 ` [PATCH net-next 2/2] Bonding: force user to add HWTSTAMP_FLAGS_UNSTABLE_PHC when get/set HWTSTAMP Hangbin Liu
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=YbBQZUoQjDC6Ea23@Laptop-X1 \
--to=liuhangbin@gmail.com \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=j.vosburgh@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=vfalico@gmail.com \
/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