How to apply a patch for Linux source code

For example, I need to apply this patch for my Linux source code: http://git.kernel.org/cgit/linux/kernel/git/davem/net.git/diff/?id=fe82b3300ec9c0dc4ba871f9a58b265aadf4e186

First, I copy this paragraph to a file in local directory: /usr/src/linux-4.3/patch.file.

"

diff --git a/net/mpls/mpls_iptunnel.c b/net/mpls/mpls_iptunnel.c
index 67591ae..64afd3d 100644
--- a/ net/mpls/mpls_iptunnel.c
+++ b/ net/mpls/mpls_iptunnel.c
@@ -54,10 +54,10 @@ int mpls_output(struct net *net, struct sock *sk, struct sk_buff *skb)
unsigned int ttl;
 
/* Obtain the ttl */
- if (skb->protocol == htons(ETH_P_IP)) {
+ if (dst->ops->family == AF_INET) {
ttl = ip_hdr(skb)->ttl;
rt = (struct rtable *)dst;
- } else if (skb->protocol == htons(ETH_P_IPV6)) {
+ } else if (dst->ops->family == AF_INET6) {
ttl = ipv6_hdr(skb)->hop_limit;
rt6 = (struct rt6_info *)dst;
} else {

"

and then use this command to do the patch:

# patch < patch.file

and then I got the warning info:

"

can't find file to patch at input line 5
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/net/mpls/mpls_iptunnel.c b/net/mpls/mpls_iptunnel.c
|index 67591ae..64afd3d 100644
|--- a/net/mpls/mpls_iptunnel.c
|+++ b/net/mpls/mpls_iptunnel.c
--------------------------
File to patch:

"

I ignore the warning and input the file name: net/mpls/mpls_iptunnel.c

And then the patch is applied.

转载于:https://www.cnblogs.com/dxh1231/p/5435640.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值