How to apply a patch for Linux source code

Source: Internet
Author: User
Tags diff htons

For example, I need to apply this patch for my Linux source code:http://git.kernel.org/cgit/linux/kernel/git/davem/net.gi t/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) u  nsigned 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_ine T6) {ttl = IPV6_HDR (SKB)->hop_limit; rt6 = (struct rt6_info *) DST;} else {

"

And then use this command to the patch:

# Patch < Patch.file

And then I got the warning info:

"

Can ' t find file to patch on input line 5
Perhaps should have used the-p or--strip option?
The text leading up to this is:
--------------------------
|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.

How to apply a patch for Linux source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.