diff options
author | Wei Zhang <asuka.com@163.com> | 2014-06-28 15:34:53 -0400 |
---|---|---|
committer | Pravin B Shelar <pshelar@nicira.com> | 2014-06-29 17:10:48 -0400 |
commit | e0bb8c44ed5cfcc56b571758ed966ee48779024c (patch) | |
tree | be67488d53526607888b26803f2445029c3e8470 /net/openvswitch/vport-gre.c | |
parent | fe984c08e20f0fc2b4666bf8eeeb02605568387b (diff) |
openvswitch: supply a dummy err_handler of gre_cisco_protocol to prevent kernel crash
When use gre vport, openvswitch register a gre_cisco_protocol but
does not supply a err_handler with it. The gre_cisco_err() in
net/ipv4/gre_demux.c expect err_handler be provided with the
gre_cisco_protocol implementation, and call ->err_handler() without
existence check, cause the kernel crash.
This patch provide a err_handler to fix this bug.
This bug introduced by commit aa310701e787087d (openvswitch: Add gre
tunnel support.)
Signed-off-by: Wei Zhang <asuka.com@163.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Diffstat (limited to 'net/openvswitch/vport-gre.c')
-rw-r--r-- | net/openvswitch/vport-gre.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/net/openvswitch/vport-gre.c b/net/openvswitch/vport-gre.c index 35ec4fed09e2..f49148a07da2 100644 --- a/net/openvswitch/vport-gre.c +++ b/net/openvswitch/vport-gre.c | |||
@@ -110,6 +110,22 @@ static int gre_rcv(struct sk_buff *skb, | |||
110 | return PACKET_RCVD; | 110 | return PACKET_RCVD; |
111 | } | 111 | } |
112 | 112 | ||
113 | /* Called with rcu_read_lock and BH disabled. */ | ||
114 | static int gre_err(struct sk_buff *skb, u32 info, | ||
115 | const struct tnl_ptk_info *tpi) | ||
116 | { | ||
117 | struct ovs_net *ovs_net; | ||
118 | struct vport *vport; | ||
119 | |||
120 | ovs_net = net_generic(dev_net(skb->dev), ovs_net_id); | ||
121 | vport = rcu_dereference(ovs_net->vport_net.gre_vport); | ||
122 | |||
123 | if (unlikely(!vport)) | ||
124 | return PACKET_REJECT; | ||
125 | else | ||
126 | return PACKET_RCVD; | ||
127 | } | ||
128 | |||
113 | static int gre_tnl_send(struct vport *vport, struct sk_buff *skb) | 129 | static int gre_tnl_send(struct vport *vport, struct sk_buff *skb) |
114 | { | 130 | { |
115 | struct net *net = ovs_dp_get_net(vport->dp); | 131 | struct net *net = ovs_dp_get_net(vport->dp); |
@@ -186,6 +202,7 @@ error: | |||
186 | 202 | ||
187 | static struct gre_cisco_protocol gre_protocol = { | 203 | static struct gre_cisco_protocol gre_protocol = { |
188 | .handler = gre_rcv, | 204 | .handler = gre_rcv, |
205 | .err_handler = gre_err, | ||
189 | .priority = 1, | 206 | .priority = 1, |
190 | }; | 207 | }; |
191 | 208 | ||