Thread (6 messages) 6 messages, 2 authors, 2021-12-09

Re: [PATCHv2 net-next 1/2] net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX

flat view

From: Richard Cochran <richardcochran@gmail.com>
Date: 2021-12-09 21:27:58

On Thu, Dec 09, 2021 at 06:24:48PM +0800, Hangbin Liu wrote:
quoted hunk ↗ jump to hunk
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 1d309a666932..10ac5457dcbc 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -186,18 +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 flag;
 	int rx_filter_valid = 0;
+	int tx_type_valid = 0;
+	int flag_valid = 0;
 
 	if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
 		return -EFAULT;
 
-	if (cfg.flags) /* reserved for future extensions */
-		return -EINVAL;
-
+	flag = cfg.flags;
 	tx_type = cfg.tx_type;
 	rx_filter = cfg.rx_filter;
 
+	switch (flag) {
+	case HWTSTAMP_FLAG_BONDED_PHC_INDEX:
+		flag_valid = 1;
This isn't correct.  You need to use a bitwise test.

Thanks,
Richard

quoted hunk ↗ jump to hunk
+		break;
+	case __HWTSTAMP_FLAGS_CNT:
+		/* not a real value */
+		break;
+	}
+
 	switch (tx_type) {
 	case HWTSTAMP_TX_OFF:
 	case HWTSTAMP_TX_ON:
@@ -234,7 +243,7 @@ static int net_hwtstamp_validate(struct ifreq *ifr)
 		break;
 	}
 
-	if (!tx_type_valid || !rx_filter_valid)
+	if (!flag_valid || !tx_type_valid || !rx_filter_valid)
 		return -ERANGE;
 
 	return 0;
-- 
2.31.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help