OSDN Git Service

net: sock: add sock_set_mark
authorAlexander Aring <aahringo@redhat.com>
Fri, 26 Jun 2020 17:26:48 +0000 (13:26 -0400)
committerDavid Teigland <teigland@redhat.com>
Thu, 6 Aug 2020 15:30:50 +0000 (10:30 -0500)
This patch adds a new socket helper function to set the mark value for a
kernel socket.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
include/net/sock.h
net/core/sock.c

index c53cc42..591dd3f 100644 (file)
@@ -2696,6 +2696,7 @@ void sock_no_linger(struct sock *sk);
 void sock_set_keepalive(struct sock *sk);
 void sock_set_priority(struct sock *sk, u32 priority);
 void sock_set_rcvbuf(struct sock *sk, int val);
+void sock_set_mark(struct sock *sk, u32 val);
 void sock_set_reuseaddr(struct sock *sk);
 void sock_set_reuseport(struct sock *sk);
 void sock_set_sndtimeo(struct sock *sk, s64 secs);
index 6c4acf1..ea6e834 100644 (file)
@@ -828,6 +828,14 @@ void sock_set_rcvbuf(struct sock *sk, int val)
 }
 EXPORT_SYMBOL(sock_set_rcvbuf);
 
+void sock_set_mark(struct sock *sk, u32 val)
+{
+       lock_sock(sk);
+       sk->sk_mark = val;
+       release_sock(sk);
+}
+EXPORT_SYMBOL(sock_set_mark);
+
 /*
  *     This is meant for all protocols to use and covers goings on
  *     at the socket level. Everything here is generic.