]> Git Repo - linux.git/blobdiff - net/ipv4/raw.c
ipmr, ip6mr: Unite vif seq functions
[linux.git] / net / ipv4 / raw.c
index 125c1eab3eaa6d894804c3aa8918aa7fcc736ca0..54648d20bf0f87e1b9a2cceb7bb18a31c8df319a 100644 (file)
@@ -520,9 +520,11 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
                goto out;
 
        /* hdrincl should be READ_ONCE(inet->hdrincl)
-        * but READ_ONCE() doesn't work with bit fields
+        * but READ_ONCE() doesn't work with bit fields.
+        * Doing this indirectly yields the same result.
         */
        hdrincl = inet->hdrincl;
+       hdrincl = READ_ONCE(hdrincl);
        /*
         *      Check the flags.
         */
@@ -615,8 +617,21 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
                        ipc.oif = inet->mc_index;
                if (!saddr)
                        saddr = inet->mc_addr;
-       } else if (!ipc.oif)
+       } else if (!ipc.oif) {
                ipc.oif = inet->uc_index;
+       } else if (ipv4_is_lbcast(daddr) && inet->uc_index) {
+               /* oif is set, packet is to local broadcast and
+                * and uc_index is set. oif is most likely set
+                * by sk_bound_dev_if. If uc_index != oif check if the
+                * oif is an L3 master and uc_index is an L3 slave.
+                * If so, we want to allow the send using the uc_index.
+                */
+               if (ipc.oif != inet->uc_index &&
+                   ipc.oif == l3mdev_master_ifindex_by_index(sock_net(sk),
+                                                             inet->uc_index)) {
+                       ipc.oif = inet->uc_index;
+               }
+       }
 
        flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos,
                           RT_SCOPE_UNIVERSE,
@@ -975,6 +990,8 @@ struct proto raw_prot = {
        .hash              = raw_hash_sk,
        .unhash            = raw_unhash_sk,
        .obj_size          = sizeof(struct raw_sock),
+       .useroffset        = offsetof(struct raw_sock, filter),
+       .usersize          = sizeof_field(struct raw_sock, filter),
        .h.raw_hash        = &raw_v4_hashinfo,
 #ifdef CONFIG_COMPAT
        .compat_setsockopt = compat_raw_setsockopt,
@@ -1117,7 +1134,6 @@ static int raw_v4_seq_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations raw_seq_fops = {
-       .owner   = THIS_MODULE,
        .open    = raw_v4_seq_open,
        .read    = seq_read,
        .llseek  = seq_lseek,
@@ -1140,6 +1156,7 @@ static __net_exit void raw_exit_net(struct net *net)
 static __net_initdata struct pernet_operations raw_net_ops = {
        .init = raw_init_net,
        .exit = raw_exit_net,
+       .async = true,
 };
 
 int __init raw_proc_init(void)
This page took 0.034729 seconds and 4 git commands to generate.