Generalize packet socket binding so that types other than ETH_P_IP can
be used.

Signed-off-by: Joe Damato <[email protected]>
---
 tools/testing/selftests/net/psock_snd.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/psock_snd.c 
b/tools/testing/selftests/net/psock_snd.c
index 3313a15e0ca1..bb9a9cfdbe95 100644
--- a/tools/testing/selftests/net/psock_snd.c
+++ b/tools/testing/selftests/net/psock_snd.c
@@ -171,12 +171,12 @@ static int build_packet(int payload_len)
        return off + payload_len;
 }
 
-static void do_bind(int fd)
+static void do_bind_proto(int fd, uint16_t proto)
 {
        struct sockaddr_ll laddr = {0};
 
        laddr.sll_family = AF_PACKET;
-       laddr.sll_protocol = htons(ETH_P_IP);
+       laddr.sll_protocol = htons(proto);
        laddr.sll_ifindex = if_nametoindex(cfg_ifname);
        if (!laddr.sll_ifindex)
                error(1, errno, "if_nametoindex");
@@ -185,6 +185,11 @@ static void do_bind(int fd)
                error(1, errno, "bind");
 }
 
+static void do_bind(int fd)
+{
+       do_bind_proto(fd, ETH_P_IP);
+}
+
 static void do_send(int fd, char *buf, int len)
 {
        int ret;
-- 
2.53.0-Meta


Reply via email to