Skip to content

Commit 7f9048f

Browse files
jacob-kellerdavem330
authored andcommitted
net: reject PTP periodic output requests with unsupported flags
Commit 823eb2a ("PTP: add support for one-shot output") introduced a new flag for the PTP periodic output request ioctl. This flag is not currently supported by any driver. Fix all drivers which implement the periodic output request ioctl to explicitly reject any request with flags they do not understand. This ensures that the driver does not accidentally misinterpret the PTP_PEROUT_ONE_SHOT flag, or any new flag introduced in the future. This is important for forward compatibility: if a new flag is introduced, the driver should reject requests to enable the flag until the driver has actually been modified to support the flag in question. Cc: Felipe Balbi <[email protected]> Cc: David S. Miller <[email protected]> Cc: Christopher Hall <[email protected]> Signed-off-by: Jacob Keller <[email protected]> Signed-off-by: Richard Cochran <[email protected]> Tested-by: Aaron Brown <[email protected]> Reviewed-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cd734d5 commit 7f9048f

File tree

7 files changed

+27
-0
lines changed

7 files changed

+27
-0
lines changed

drivers/net/ethernet/broadcom/tg3.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6280,6 +6280,10 @@ static int tg3_ptp_enable(struct ptp_clock_info *ptp,
62806280

62816281
switch (rq->type) {
62826282
case PTP_CLK_REQ_PEROUT:
6283+
/* Reject requests with unsupported flags */
6284+
if (rq->perout.flags)
6285+
return -EOPNOTSUPP;
6286+
62836287
if (rq->perout.index != 0)
62846288
return -EINVAL;
62856289

drivers/net/ethernet/intel/igb/igb_ptp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,10 @@ static int igb_ptp_feature_enable_i210(struct ptp_clock_info *ptp,
551551
return 0;
552552

553553
case PTP_CLK_REQ_PEROUT:
554+
/* Reject requests with unsupported flags */
555+
if (rq->perout.flags)
556+
return -EOPNOTSUPP;
557+
554558
if (on) {
555559
pin = ptp_find_pin(igb->ptp_clock, PTP_PF_PEROUT,
556560
rq->perout.index);

drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp,
290290
if (!MLX5_PPS_CAP(mdev))
291291
return -EOPNOTSUPP;
292292

293+
/* Reject requests with unsupported flags */
294+
if (rq->perout.flags)
295+
return -EOPNOTSUPP;
296+
293297
if (rq->perout.index >= clock->ptp_info.n_pins)
294298
return -EINVAL;
295299

drivers/net/ethernet/microchip/lan743x_ptp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ static int lan743x_ptp_perout(struct lan743x_adapter *adapter, int on,
429429
int pulse_width = 0;
430430
int perout_bit = 0;
431431

432+
/* Reject requests with unsupported flags */
433+
if (perout->flags)
434+
return -EOPNOTSUPP;
435+
432436
if (!on) {
433437
lan743x_ptp_perout_off(adapter);
434438
return 0;

drivers/net/ethernet/renesas/ravb_ptp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ static int ravb_ptp_perout(struct ptp_clock_info *ptp,
211211
unsigned long flags;
212212
int error = 0;
213213

214+
/* Reject requests with unsupported flags */
215+
if (req->flags)
216+
return -EOPNOTSUPP;
217+
214218
if (req->index)
215219
return -EINVAL;
216220

drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ static int stmmac_enable(struct ptp_clock_info *ptp,
140140

141141
switch (rq->type) {
142142
case PTP_CLK_REQ_PEROUT:
143+
/* Reject requests with unsupported flags */
144+
if (rq->perout.flags)
145+
return -EOPNOTSUPP;
146+
143147
cfg = &priv->pps[rq->perout.index];
144148

145149
cfg->start.tv_sec = rq->perout.start.sec;

drivers/net/phy/dp83640.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp,
491491
return 0;
492492

493493
case PTP_CLK_REQ_PEROUT:
494+
/* Reject requests with unsupported flags */
495+
if (rq->perout.flags)
496+
return -EOPNOTSUPP;
494497
if (rq->perout.index >= N_PER_OUT)
495498
return -EINVAL;
496499
return periodic_output(clock, rq, on, rq->perout.index);

0 commit comments

Comments
 (0)