diff options
author | Vlad Yasevich <vyasevic@redhat.com> | 2012-11-15 03:49:23 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-15 17:39:51 -0500 |
commit | f191a1d17f227032c159e5499809f545402b6dc6 (patch) | |
tree | 48fc87a0b34bd2da06fedcd7e5e3ed6b08f7a3ac /net/ipv4/af_inet.c | |
parent | c6b641a4c6b32f39db678c2441cb1ef824110d74 (diff) |
net: Remove code duplication between offload structures
Move the offload callbacks into its own structure.
Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/af_inet.c')
-rw-r--r-- | net/ipv4/af_inet.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 9f2e7fd8bea8..d5e5a054123c 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -1276,8 +1276,8 @@ static int inet_gso_send_check(struct sk_buff *skb) | |||
1276 | 1276 | ||
1277 | rcu_read_lock(); | 1277 | rcu_read_lock(); |
1278 | ops = rcu_dereference(inet_offloads[proto]); | 1278 | ops = rcu_dereference(inet_offloads[proto]); |
1279 | if (likely(ops && ops->gso_send_check)) | 1279 | if (likely(ops && ops->callbacks.gso_send_check)) |
1280 | err = ops->gso_send_check(skb); | 1280 | err = ops->callbacks.gso_send_check(skb); |
1281 | rcu_read_unlock(); | 1281 | rcu_read_unlock(); |
1282 | 1282 | ||
1283 | out: | 1283 | out: |
@@ -1326,8 +1326,8 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, | |||
1326 | 1326 | ||
1327 | rcu_read_lock(); | 1327 | rcu_read_lock(); |
1328 | ops = rcu_dereference(inet_offloads[proto]); | 1328 | ops = rcu_dereference(inet_offloads[proto]); |
1329 | if (likely(ops && ops->gso_segment)) | 1329 | if (likely(ops && ops->callbacks.gso_segment)) |
1330 | segs = ops->gso_segment(skb, features); | 1330 | segs = ops->callbacks.gso_segment(skb, features); |
1331 | rcu_read_unlock(); | 1331 | rcu_read_unlock(); |
1332 | 1332 | ||
1333 | if (!segs || IS_ERR(segs)) | 1333 | if (!segs || IS_ERR(segs)) |
@@ -1379,7 +1379,7 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head, | |||
1379 | 1379 | ||
1380 | rcu_read_lock(); | 1380 | rcu_read_lock(); |
1381 | ops = rcu_dereference(inet_offloads[proto]); | 1381 | ops = rcu_dereference(inet_offloads[proto]); |
1382 | if (!ops || !ops->gro_receive) | 1382 | if (!ops || !ops->callbacks.gro_receive) |
1383 | goto out_unlock; | 1383 | goto out_unlock; |
1384 | 1384 | ||
1385 | if (*(u8 *)iph != 0x45) | 1385 | if (*(u8 *)iph != 0x45) |
@@ -1420,7 +1420,7 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head, | |||
1420 | skb_gro_pull(skb, sizeof(*iph)); | 1420 | skb_gro_pull(skb, sizeof(*iph)); |
1421 | skb_set_transport_header(skb, skb_gro_offset(skb)); | 1421 | skb_set_transport_header(skb, skb_gro_offset(skb)); |
1422 | 1422 | ||
1423 | pp = ops->gro_receive(head, skb); | 1423 | pp = ops->callbacks.gro_receive(head, skb); |
1424 | 1424 | ||
1425 | out_unlock: | 1425 | out_unlock: |
1426 | rcu_read_unlock(); | 1426 | rcu_read_unlock(); |
@@ -1444,10 +1444,10 @@ static int inet_gro_complete(struct sk_buff *skb) | |||
1444 | 1444 | ||
1445 | rcu_read_lock(); | 1445 | rcu_read_lock(); |
1446 | ops = rcu_dereference(inet_offloads[proto]); | 1446 | ops = rcu_dereference(inet_offloads[proto]); |
1447 | if (WARN_ON(!ops || !ops->gro_complete)) | 1447 | if (WARN_ON(!ops || !ops->callbacks.gro_complete)) |
1448 | goto out_unlock; | 1448 | goto out_unlock; |
1449 | 1449 | ||
1450 | err = ops->gro_complete(skb); | 1450 | err = ops->callbacks.gro_complete(skb); |
1451 | 1451 | ||
1452 | out_unlock: | 1452 | out_unlock: |
1453 | rcu_read_unlock(); | 1453 | rcu_read_unlock(); |
@@ -1563,10 +1563,12 @@ static const struct net_protocol tcp_protocol = { | |||
1563 | }; | 1563 | }; |
1564 | 1564 | ||
1565 | static const struct net_offload tcp_offload = { | 1565 | static const struct net_offload tcp_offload = { |
1566 | .gso_send_check = tcp_v4_gso_send_check, | 1566 | .callbacks = { |
1567 | .gso_segment = tcp_tso_segment, | 1567 | .gso_send_check = tcp_v4_gso_send_check, |
1568 | .gro_receive = tcp4_gro_receive, | 1568 | .gso_segment = tcp_tso_segment, |
1569 | .gro_complete = tcp4_gro_complete, | 1569 | .gro_receive = tcp4_gro_receive, |
1570 | .gro_complete = tcp4_gro_complete, | ||
1571 | }, | ||
1570 | }; | 1572 | }; |
1571 | 1573 | ||
1572 | static const struct net_protocol udp_protocol = { | 1574 | static const struct net_protocol udp_protocol = { |
@@ -1577,8 +1579,10 @@ static const struct net_protocol udp_protocol = { | |||
1577 | }; | 1579 | }; |
1578 | 1580 | ||
1579 | static const struct net_offload udp_offload = { | 1581 | static const struct net_offload udp_offload = { |
1580 | .gso_send_check = udp4_ufo_send_check, | 1582 | .callbacks = { |
1581 | .gso_segment = udp4_ufo_fragment, | 1583 | .gso_send_check = udp4_ufo_send_check, |
1584 | .gso_segment = udp4_ufo_fragment, | ||
1585 | }, | ||
1582 | }; | 1586 | }; |
1583 | 1587 | ||
1584 | static const struct net_protocol icmp_protocol = { | 1588 | static const struct net_protocol icmp_protocol = { |
@@ -1667,10 +1671,12 @@ static int ipv4_proc_init(void); | |||
1667 | 1671 | ||
1668 | static struct packet_offload ip_packet_offload __read_mostly = { | 1672 | static struct packet_offload ip_packet_offload __read_mostly = { |
1669 | .type = cpu_to_be16(ETH_P_IP), | 1673 | .type = cpu_to_be16(ETH_P_IP), |
1670 | .gso_send_check = inet_gso_send_check, | 1674 | .callbacks = { |
1671 | .gso_segment = inet_gso_segment, | 1675 | .gso_send_check = inet_gso_send_check, |
1672 | .gro_receive = inet_gro_receive, | 1676 | .gso_segment = inet_gso_segment, |
1673 | .gro_complete = inet_gro_complete, | 1677 | .gro_receive = inet_gro_receive, |
1678 | .gro_complete = inet_gro_complete, | ||
1679 | }, | ||
1674 | }; | 1680 | }; |
1675 | 1681 | ||
1676 | static int __init ipv4_offload_init(void) | 1682 | static int __init ipv4_offload_init(void) |