@@ -5689,10 +5689,11 @@ static int selinux_tun_dev_open(void *security)
5689
5689
5690
5690
#ifdef CONFIG_NETFILTER
5691
5691
5692
- static unsigned int selinux_ip_forward (struct sk_buff * skb ,
5693
- const struct net_device * indev ,
5694
- u16 family )
5692
+ static unsigned int selinux_ip_forward (void * priv , struct sk_buff * skb ,
5693
+ const struct nf_hook_state * state )
5695
5694
{
5695
+ const struct net_device * indev = state -> in ;
5696
+ u16 family = state -> pf ;
5696
5697
int err ;
5697
5698
char * addrp ;
5698
5699
u32 peer_sid ;
@@ -5747,25 +5748,10 @@ static unsigned int selinux_ip_forward(struct sk_buff *skb,
5747
5748
return NF_ACCEPT ;
5748
5749
}
5749
5750
5750
- static unsigned int selinux_ipv4_forward (void * priv ,
5751
- struct sk_buff * skb ,
5752
- const struct nf_hook_state * state )
5753
- {
5754
- return selinux_ip_forward (skb , state -> in , PF_INET );
5755
- }
5756
-
5757
- #if IS_ENABLED (CONFIG_IPV6 )
5758
- static unsigned int selinux_ipv6_forward (void * priv ,
5759
- struct sk_buff * skb ,
5760
- const struct nf_hook_state * state )
5761
- {
5762
- return selinux_ip_forward (skb , state -> in , PF_INET6 );
5763
- }
5764
- #endif /* IPV6 */
5765
-
5766
- static unsigned int selinux_ip_output (struct sk_buff * skb ,
5767
- u16 family )
5751
+ static unsigned int selinux_ip_output (void * priv , struct sk_buff * skb ,
5752
+ const struct nf_hook_state * state )
5768
5753
{
5754
+ u16 family = state -> pf ;
5769
5755
struct sock * sk ;
5770
5756
u32 sid ;
5771
5757
@@ -5805,21 +5791,6 @@ static unsigned int selinux_ip_output(struct sk_buff *skb,
5805
5791
return NF_ACCEPT ;
5806
5792
}
5807
5793
5808
- static unsigned int selinux_ipv4_output (void * priv ,
5809
- struct sk_buff * skb ,
5810
- const struct nf_hook_state * state )
5811
- {
5812
- return selinux_ip_output (skb , PF_INET );
5813
- }
5814
-
5815
- #if IS_ENABLED (CONFIG_IPV6 )
5816
- static unsigned int selinux_ipv6_output (void * priv ,
5817
- struct sk_buff * skb ,
5818
- const struct nf_hook_state * state )
5819
- {
5820
- return selinux_ip_output (skb , PF_INET6 );
5821
- }
5822
- #endif /* IPV6 */
5823
5794
5824
5795
static unsigned int selinux_ip_postroute_compat (struct sk_buff * skb ,
5825
5796
int ifindex ,
@@ -5855,10 +5826,12 @@ static unsigned int selinux_ip_postroute_compat(struct sk_buff *skb,
5855
5826
return NF_ACCEPT ;
5856
5827
}
5857
5828
5858
- static unsigned int selinux_ip_postroute (struct sk_buff * skb ,
5859
- const struct net_device * outdev ,
5860
- u16 family )
5829
+ static unsigned int selinux_ip_postroute (void * priv ,
5830
+ struct sk_buff * skb ,
5831
+ const struct nf_hook_state * state )
5861
5832
{
5833
+ const struct net_device * outdev = state -> out ;
5834
+ u16 family = state -> pf ;
5862
5835
u32 secmark_perm ;
5863
5836
u32 peer_sid ;
5864
5837
int ifindex = outdev -> ifindex ;
@@ -5994,23 +5967,6 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb,
5994
5967
5995
5968
return NF_ACCEPT ;
5996
5969
}
5997
-
5998
- static unsigned int selinux_ipv4_postroute (void * priv ,
5999
- struct sk_buff * skb ,
6000
- const struct nf_hook_state * state )
6001
- {
6002
- return selinux_ip_postroute (skb , state -> out , PF_INET );
6003
- }
6004
-
6005
- #if IS_ENABLED (CONFIG_IPV6 )
6006
- static unsigned int selinux_ipv6_postroute (void * priv ,
6007
- struct sk_buff * skb ,
6008
- const struct nf_hook_state * state )
6009
- {
6010
- return selinux_ip_postroute (skb , state -> out , PF_INET6 );
6011
- }
6012
- #endif /* IPV6 */
6013
-
6014
5970
#endif /* CONFIG_NETFILTER */
6015
5971
6016
5972
static int selinux_netlink_send (struct sock * sk , struct sk_buff * skb )
@@ -7475,38 +7431,38 @@ DEFINE_LSM(selinux) = {
7475
7431
7476
7432
static const struct nf_hook_ops selinux_nf_ops [] = {
7477
7433
{
7478
- .hook = selinux_ipv4_postroute ,
7434
+ .hook = selinux_ip_postroute ,
7479
7435
.pf = NFPROTO_IPV4 ,
7480
7436
.hooknum = NF_INET_POST_ROUTING ,
7481
7437
.priority = NF_IP_PRI_SELINUX_LAST ,
7482
7438
},
7483
7439
{
7484
- .hook = selinux_ipv4_forward ,
7440
+ .hook = selinux_ip_forward ,
7485
7441
.pf = NFPROTO_IPV4 ,
7486
7442
.hooknum = NF_INET_FORWARD ,
7487
7443
.priority = NF_IP_PRI_SELINUX_FIRST ,
7488
7444
},
7489
7445
{
7490
- .hook = selinux_ipv4_output ,
7446
+ .hook = selinux_ip_output ,
7491
7447
.pf = NFPROTO_IPV4 ,
7492
7448
.hooknum = NF_INET_LOCAL_OUT ,
7493
7449
.priority = NF_IP_PRI_SELINUX_FIRST ,
7494
7450
},
7495
7451
#if IS_ENABLED (CONFIG_IPV6 )
7496
7452
{
7497
- .hook = selinux_ipv6_postroute ,
7453
+ .hook = selinux_ip_postroute ,
7498
7454
.pf = NFPROTO_IPV6 ,
7499
7455
.hooknum = NF_INET_POST_ROUTING ,
7500
7456
.priority = NF_IP6_PRI_SELINUX_LAST ,
7501
7457
},
7502
7458
{
7503
- .hook = selinux_ipv6_forward ,
7459
+ .hook = selinux_ip_forward ,
7504
7460
.pf = NFPROTO_IPV6 ,
7505
7461
.hooknum = NF_INET_FORWARD ,
7506
7462
.priority = NF_IP6_PRI_SELINUX_FIRST ,
7507
7463
},
7508
7464
{
7509
- .hook = selinux_ipv6_output ,
7465
+ .hook = selinux_ip_output ,
7510
7466
.pf = NFPROTO_IPV6 ,
7511
7467
.hooknum = NF_INET_LOCAL_OUT ,
7512
7468
.priority = NF_IP6_PRI_SELINUX_FIRST ,
0 commit comments