s390/qeth: extract helper to determine L2 cast type
authorJulian Wiedmann <jwi@linux.ibm.com>
Thu, 25 Apr 2019 16:26:00 +0000 (18:26 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 26 Apr 2019 15:14:06 +0000 (11:14 -0400)
This de-duplicates the L2 and L3 cast-type code, and makes the L2 code
a bit more robust by removing the fragile assumption that skb->data
always points to the Ethernet Header. This would break in code paths
where we pushed the HW header onto the skb.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/qeth_core.h
drivers/s390/net/qeth_l2_main.c
drivers/s390/net/qeth_l3_main.c

index 73afbb8b69e56f7ed7bbee1f4b7ba066ef714755..784a2e76a1b04a45f13399a73244e59493bcb733 100644 (file)
@@ -881,6 +881,16 @@ static inline int qeth_get_ip_version(struct sk_buff *skb)
        }
 }
 
+static inline int qeth_get_ether_cast_type(struct sk_buff *skb)
+{
+       u8 *addr = eth_hdr(skb)->h_dest;
+
+       if (is_multicast_ether_addr(addr))
+               return is_broadcast_ether_addr(addr) ? RTN_BROADCAST :
+                                                      RTN_MULTICAST;
+       return RTN_UNICAST;
+}
+
 static inline void qeth_rx_csum(struct qeth_card *card, struct sk_buff *skb,
                                u8 flags)
 {
index cee9a99dd463c2167681f92a4c5aaf5abb56385c..218801232ca2609671f12ce4a99ae1dfd04d315f 100644 (file)
@@ -161,15 +161,6 @@ static void qeth_l2_drain_rx_mode_cache(struct qeth_card *card)
        }
 }
 
-static int qeth_l2_get_cast_type(struct sk_buff *skb)
-{
-       if (is_broadcast_ether_addr(skb->data))
-               return RTN_BROADCAST;
-       if (is_multicast_ether_addr(skb->data))
-               return RTN_MULTICAST;
-       return RTN_UNICAST;
-}
-
 static void qeth_l2_fill_header(struct qeth_qdio_out_q *queue,
                                struct qeth_hdr *hdr, struct sk_buff *skb,
                                int ipv, int cast_type, unsigned int data_len)
@@ -611,7 +602,8 @@ static netdev_tx_t qeth_l2_hard_start_xmit(struct sk_buff *skb,
                rc = qeth_l2_xmit_osn(card, skb, queue);
        else
                rc = qeth_xmit(card, skb, queue, qeth_get_ip_version(skb),
-                              qeth_l2_get_cast_type(skb), qeth_l2_fill_header);
+                              qeth_get_ether_cast_type(skb),
+                              qeth_l2_fill_header);
 
        if (!rc) {
                QETH_TXQ_STAT_INC(queue, tx_packets);
@@ -631,7 +623,7 @@ static u16 qeth_l2_select_queue(struct net_device *dev, struct sk_buff *skb,
 
        if (IS_IQD(card))
                return qeth_iqd_select_queue(dev, skb,
-                                            qeth_l2_get_cast_type(skb),
+                                            qeth_get_ether_cast_type(skb),
                                             sb_dev);
        return qeth_get_priority_queue(card, skb);
 }
index 8fd634229871e62f7ba6cc325958a708b0b0ed32..b5d76ebb488a3e8a4fd2d7f6af10ae02cdb3b4a3 100644 (file)
@@ -1918,13 +1918,7 @@ static int qeth_l3_get_cast_type(struct sk_buff *skb)
                                RTN_MULTICAST : RTN_UNICAST;
        default:
                /* ... and MAC address */
-               if (ether_addr_equal_64bits(eth_hdr(skb)->h_dest,
-                                           skb->dev->broadcast))
-                       return RTN_BROADCAST;
-               if (is_multicast_ether_addr(eth_hdr(skb)->h_dest))
-                       return RTN_MULTICAST;
-               /* default to unicast */
-               return RTN_UNICAST;
+               return qeth_get_ether_cast_type(skb);
        }
 }