net: reject PTP periodic output requests with unsupported flags
authorJacob Keller <jacob.e.keller@intel.com>
Thu, 14 Nov 2019 18:44:56 +0000 (10:44 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 15 Nov 2019 20:48:32 +0000 (12:48 -0800)
Commit 823eb2a3c4c7 ("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 <felipe.balbi@linux.intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Christopher Hall <christopher.s.hall@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Reviewed-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/tg3.c
drivers/net/ethernet/intel/igb/igb_ptp.c
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
drivers/net/ethernet/microchip/lan743x_ptp.c
drivers/net/ethernet/renesas/ravb_ptp.c
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
drivers/net/phy/dp83640.c

index 77f3511b97dee1491bba2f1307e8b14ba8f8f575..ca3aa1250dd1381f67950177762a3e0215e74a43 100644 (file)
@@ -6280,6 +6280,10 @@ static int tg3_ptp_enable(struct ptp_clock_info *ptp,
 
        switch (rq->type) {
        case PTP_CLK_REQ_PEROUT:
+               /* Reject requests with unsupported flags */
+               if (rq->perout.flags)
+                       return -EOPNOTSUPP;
+
                if (rq->perout.index != 0)
                        return -EINVAL;
 
index fd3071f55bd34c07e55c15688216e80659cdc187..4997963149f6ab062abf9d33f585d3aba376fc27 100644 (file)
@@ -551,6 +551,10 @@ static int igb_ptp_feature_enable_i210(struct ptp_clock_info *ptp,
                return 0;
 
        case PTP_CLK_REQ_PEROUT:
+               /* Reject requests with unsupported flags */
+               if (rq->perout.flags)
+                       return -EOPNOTSUPP;
+
                if (on) {
                        pin = ptp_find_pin(igb->ptp_clock, PTP_PF_PEROUT,
                                           rq->perout.index);
index 0059b290e09572aa7bb8a6f7233fc4a235cc3b76..cff6b60de304df5702dfb160850f992f09dfe185 100644 (file)
@@ -290,6 +290,10 @@ static int mlx5_perout_configure(struct ptp_clock_info *ptp,
        if (!MLX5_PPS_CAP(mdev))
                return -EOPNOTSUPP;
 
+       /* Reject requests with unsupported flags */
+       if (rq->perout.flags)
+               return -EOPNOTSUPP;
+
        if (rq->perout.index >= clock->ptp_info.n_pins)
                return -EINVAL;
 
index 57b26c2acf877a3bc9fa974eaf24191e81ffac49..e8fe9a90fe4f9b99a37ccdc0b3c9bdb5fd8d62a6 100644 (file)
@@ -429,6 +429,10 @@ static int lan743x_ptp_perout(struct lan743x_adapter *adapter, int on,
        int pulse_width = 0;
        int perout_bit = 0;
 
+       /* Reject requests with unsupported flags */
+       if (perout->flags)
+               return -EOPNOTSUPP;
+
        if (!on) {
                lan743x_ptp_perout_off(adapter);
                return 0;
index 9a42580693cb19faeb00e613b6572fff4ba60453..638f1fc2166f381505320bfa29cdb242179fe06b 100644 (file)
@@ -211,6 +211,10 @@ static int ravb_ptp_perout(struct ptp_clock_info *ptp,
        unsigned long flags;
        int error = 0;
 
+       /* Reject requests with unsupported flags */
+       if (req->flags)
+               return -EOPNOTSUPP;
+
        if (req->index)
                return -EINVAL;
 
index df638b18b72c7f895c6cb65b13b5119902fc30b8..0989e2bb6ee31dece215fdddd5271d1d633d2540 100644 (file)
@@ -140,6 +140,10 @@ static int stmmac_enable(struct ptp_clock_info *ptp,
 
        switch (rq->type) {
        case PTP_CLK_REQ_PEROUT:
+               /* Reject requests with unsupported flags */
+               if (rq->perout.flags)
+                       return -EOPNOTSUPP;
+
                cfg = &priv->pps[rq->perout.index];
 
                cfg->start.tv_sec = rq->perout.start.sec;
index 6580094161a9f6730e529124a08811f5ace9ff53..04ad777589202e789272c877f0f63ec0c210c00d 100644 (file)
@@ -491,6 +491,9 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp,
                return 0;
 
        case PTP_CLK_REQ_PEROUT:
+               /* Reject requests with unsupported flags */
+               if (rq->perout.flags)
+                       return -EOPNOTSUPP;
                if (rq->perout.index >= N_PER_OUT)
                        return -EINVAL;
                return periodic_output(clock, rq, on, rq->perout.index);