diff --git a/gtests/net/packetdrill/packet_socket_linux.c b/gtests/net/packetdrill/packet_socket_linux.c
index a31873a2f79c855e7fc986695005d266534fe845..d8ec4d76f814242a27d4516451159ffae29f0b65 100644
--- a/gtests/net/packetdrill/packet_socket_linux.c
+++ b/gtests/net/packetdrill/packet_socket_linux.c
@@ -168,12 +168,12 @@ void packet_socket_set_filter(struct packet_socket *psock,
 	}
 
 	/* Fill in the client-side ethernet address to look for. */
-	bpfcode.filter[1].k = ((client_ether[2] << 24) |
-			       (client_ether[3] << 16) |
-			       (client_ether[4] << 8)  |
-			       (client_ether[5]));
-	bpfcode.filter[3].k = ((client_ether[0] << 8)  |
-			       (client_ether[1]));
+	bpfcode.filter[1].k = (((u32)client_ether[2] << 24) |
+			       ((u32)client_ether[3] << 16) |
+			       ((u32)client_ether[4] << 8)  |
+			       ((u32)client_ether[5]));
+	bpfcode.filter[3].k = (((u32)client_ether[0] << 8)  |
+			       ((u32(client_ether[1]));
 
 	if (debug_logging) {
 		int i;